Is there any way to force an onChange() event for a select box on page load? I’m not able to set default values for the elements I intend to change. Thanks, JW
@voidvectorNov 29.2008 — #Just set the value in JavaScript if all you want to do is change the on/off state at start up.
If you want to simulate a user-click, it would depend on how complicated the onchange function is. If the onchange doesn't interact much with the event object, then you can probably call it directly. If the onchange interacts with the event a lot, then you need to create event object and call either "dispatchEvent" or "fireEvent"
@CuppyTeaNov 29.2008 — #Is there any way to force an onChange() event for a select box on page load? I'm not able to set default values for the elements I intend to change. Thanks,
JW[/QUOTE]
Firing an onChange event will not change the value- as the event is fired ONchange, i.e. after the change, i.e. its all a bit backwards and won't work ?
Instead of using onChange, just loop through the options and set selected=true.