views:

81

answers:

1

Hi,

I've been trying experiments with the following, but so far to no avail:

sel = document.getElementById('myComboBox')
sel.selectedIndex = 1;
sel.options[1].selected = true;
sel[1].click();

Thanks for the help!

A: 

Wait why would you write:

sel.options[1].selected = true;

and then in the very next line write

sel[1].click();

?? The element is not an array and can't be treated as one.

The "click" event might not be the best thing to handle anyway. Probably the "change" event on the select element itself would be more reliable.

Pointy
Hi Pointy, thank you for the response. Is there a way to apply the change event on the select element through JavaScript? I have a complication where I can't use the <select onchange=""> syntax.
mrentropy