[英]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: 现在我在提交按钮上有onclick事件,它可以:
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... select的选项中不存在新值。
I just need to modify the values being sent 我只需要修改发送的值
Use this code - This might help 使用此代码-这可能会有所帮助
var yourValue
$("#myselect").find("option").attr("selected", "selected").val(yourValue);
CSS pseudo selector will do the trick. CSS伪选择器可以解决问题。
var yourValue
$("#myselect").find("option:selected").val(yourValue);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.