JavaScript instance: onchange () event for Select

Source: Internet
Author: User
Select

When we use the onchange event of Select, we often encounter the problem of not triggering the onchange event when the same item is selected consecutively. The onchange event of the Select is this. You have to have change to trigger the event ....

After mastering its characteristics, the corresponding solution is also very simple.

<select Name=sel >
<option value= "" > Please Select
<option value= "1" >item 1
<option value= "2" >item 2
<option value= "3" >item 3
</select>
<script>
function Bao (s)
{
Txt.value+=s;
When you choose, let the first item be selected so that there is a change.
Document.all.sel.options[0].selected=true;
}
</script>
<textarea id=txt></textarea>



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.