如何传递这两个变量val_1
& val_2
通过表单提交到函数initComparison()
?
这是我的代码:
<form action="" onsubmit="">
<select name="val_1">
<option value="x">X</option>
<option value="y">Y</option>
<input type="text" value="Enter the product id" name="val_2">
</form>
<script type="text/javascript"> $(document).ready(function(){
initComparison('val_1','val_2','abc','def');
});</script>
答案 0 :(得分:0)
使用类似的东西
<form action="" onsubmit="">
<select name="val_1" id="val_1">
<option value="x">X</option>
<option value="y">Y</option>
</select>
<input type="text" value="Enter the product id" name="val_2" id="val_2">
<input type="button" name="submit" value="submit" id="send">
</form>
<script type="text/javascript">
$("#send").click(function(){
var var1=$("#val_1").val();
var var2=$("#val_2").val();
initComparison(val_1,val_2,'abc','def');
});
</script>