JQuery automation to mimic user iteration of web page

Hi there.

I wish to automate the population of a page by prefilling form values such as select boxes as well as fire off the change event after the value has been set. However there are at least 3/4 select boxes on one page which need populating automatically.

This works fine for the first element but not for subsequent elements all in one go when use the Trigger method of Jquery.

Can anyone suggest where I am going wrong.

e.g.

$(‘#category’).val(5);
$(‘#category’).trigger(‘change’); <– stops here.
$(‘#unit’).val(8);
$(‘#unit’).trigger(‘change’);

The change event on category seems to break the flow and does not pass control back to carry on the order of processing.

Thanks.

Phil.

Perhaps it’s throwing an error you haven’t noticed. The logic seems to work fine:

Quick test: