2016-04-17 18 views
0
<html> 
<head> 
<script type="text/javascript"> 

function changeFunc() { 
var selectBox = document.getElementById("selectBox"); 
var selectedValue = selectBox.options[selectBox.selectedIndex].value; 
alert(selectedValue); 
} 

</script> 
</head> 

<body> 
<select id="selectBox" onchange="changeFunc();"> 
<option value="1">Option #1</option> 
<option value="2">Option #2</option> 
</select> 
</body> 
</html> 

我们可以得到的SelectedValue早在JSP作为的onChange参数,并通过它来形成一个隐藏的变量,并把它回支柱作用?获取JavaScript计算值Struts动作

+1

的可能的复制[如何获得形式的JavaScript计算值(http://stackoverflow.com/questions/36671921/how-to-get-javascript-calculated在表单中的值) –

+0

*倒票最喜欢的* :) –

+0

我不知道这个问题实际上是什么 - 将值放入隐藏的窗体属性,你就完成了。 –

回答

0

我已经加入jQuery的线来填充JSP

所以每当单选按钮被点击JSP 隐藏字段的隐藏字段的值,jQuery的帮助我填充我的隐藏字段的值。

它的工作,感谢

<html:hidden name="annualPremSizeCreditForm" property="selectedRadioButtonID" value=""/> 

    var radioButtonIdDesc = $('input[type=radio][name=radioButtons]:checked').attr('id'); 
         if((radioButtonIdDesc).indexOf("fifteenPercentRadio") != -1){ 
          $('input[name=selectedRadioButtonID]').val("fifteenPercentRadio"); 
         } 
         if((radioButtonIdDesc).indexOf("tenPercentRadio") != -1){ 
          $('input[name=selectedRadioButtonID]').val("tenPercentRadio"); 
         }