Reputation: 1139
How can I change the value of a dropdown before submitting a form?
right now I have onclick event on the submit button that does:
alert(document.myform.myselect.value); //getting old value
document.rscGeneral.selectHlrId.value='x';
alert(document.myform.myselect.value);//getting null
The new value doesn't exist in options of the select...
I just need to modify the values being sent
Upvotes: 1
Views: 1082
Reputation: 400
CSS pseudo selector will do the trick.
var yourValue
$("#myselect").find("option:selected").val(yourValue);
Upvotes: 1
Reputation: 1715
Use this code - This might help
var yourValue
$("#myselect").find("option").attr("selected", "selected").val(yourValue);
Upvotes: 1