how to change the selected value in javascript and get the selected value in codebehind page? AutoPostBack is set to false.
Use the value property to set the value of a select element, e.g. select. value = 'new value' . The value property can be used to set or update the value of a select element.
Using the jQuery change() method; you can set the selected value of dropdown in jquery by using id, name, class, and tag with selected html elements; see the following example for that: Example 1 :- Set selected value of dropdown in jquery by id.
You can change it like this:
var ddl = document.getElementById('ddl-id');
var opts = ddl.options.length;
for (var i=0; i<opts; i++){
if (ddl.options[i].value == "some-value"){
ddl.options[i].selected = true;
break;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With