So what *is* the Latin word for chocolate? How to react to a students panic attack in an oral exam? How do I get the current date in JavaScript? You can use the select to submit its form: <select..onchange="this.form.submit ()"> or to tack on querystring data without submitting:. You can store this in a variable outside the anonymous function to ensure you can get the correct scope you need, this way of getting the value won't work in old browsers, use Danny's solution instead, I don't mean to be offensive, but are you sure it's a good idea to still suggest using id while a handler can use. Note: If no option is selected, the selectedIndex property will return -1. For example, using the following select box: If you wanted to get the string "Mr" if the first option was selected (instead of just "1") you would do that in the following way: Just in case someone is looking for a React solution without having to download addition dependancies you could write: Make sure to bind the changed() function in the constructor like: this code once i write for just explain onChange event of select you can save this code as html and see output it works.and easy to understand for you. Please consider editing the question to include a description about the solution. newSelect.onchange = changeitem; But this does not really allow you to specify that argument passed in, so instead you may do this: newSelect.setAttribute ('onchange', 'changeitem (this)'); And you are able to set the parameter. This approach can be used both inside and outside of an event handler function. NB. How can I change an element's class with JavaScript? run code according to the selected text on dropdown. index.html The onchange event is one of the events in JavaScript which is used for making the change in the state and transforming the value once the event is triggered. rev2023.3.1.43269. What type of value are you expecting? This is nice. We used the var text=e. javascript - select option to +100 dollar on element? On change is much better than a click event as it isn't cancerous to select an option. Making statements based on opinion; back them up with references or personal experience. Which