简体   繁体   中英

triggering an onchange event of a select box

I have a select box, which i can populate using two methods.

First - Just by selecting any one of the option in the select box.

Second - I have a link just beside the select box.Clicking this link takes me to a page2, which has the same options but as links in page2.When i click one of them , it populates the select box.

Selecting the option directly from the "select" triggers an onchange event in it. But when i click the link, select my required option from that page, it does not trigger the onchange event in the select box. I am not sure where i am doing a mistake.

Thanks in advance.

This happens because the onchange is fired only when user does selection.

There's an easy workaround... have the JS code which populates the select box call the same JS code that is called from onchange trigger of the select.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM