yuris
yuris

Reputation: 1139

Change value of selected item in dropdown before submit

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

Answers (2)

thisiskatkat
thisiskatkat

Reputation: 400

CSS pseudo selector will do the trick.

var yourValue

$("#myselect").find("option:selected").val(yourValue);

Upvotes: 1

Nikhil Chavan
Nikhil Chavan

Reputation: 1715

Use this code - This might help

var yourValue

$("#myselect").find("option").attr("selected", "selected").val(yourValue);

Upvotes: 1

Related Questions