页面设计中使用Struts的select,如何使用JS得到html:select的选择值 ?页面设计代码如下。谢谢 <body>
<br>数据上传<br>
<html:form action="/deployData">
请选择上传文件数量:
<html:select property="number" onchange="buildFileInput()">
<html:option value='1'>1</html:option>
<html:option value='2'>2</html:option>
<html:option value='3'>3</html:option>
<html:option value='4'>4</html:option>
</html:select>
<table width="200" border="0">
<tr>
<td><br>
<div id="files"></div>
<html:submit value="提交"/>
<html:cancel value="取消"/><br></td>
</tr>
</table>
</html:form>
</body>
<br>数据上传<br>
<html:form action="/deployData">
请选择上传文件数量:
<html:select property="number" onchange="buildFileInput()">
<html:option value='1'>1</html:option>
<html:option value='2'>2</html:option>
<html:option value='3'>3</html:option>
<html:option value='4'>4</html:option>
</html:select>
<table width="200" border="0">
<tr>
<td><br>
<div id="files"></div>
<html:submit value="提交"/>
<html:cancel value="取消"/><br></td>
</tr>
</table>
</html:form>
</body>
<form action="/deployData">
请选择上传文件数量:
<select property="number" onchange="buildFileInput(this)">
<option value=1>1 </html:option>
<option value=2>2 </html:option>
<option value=3>3 </html:option>
<option value=4>4 </html:option>
</select>
<table width="200" border="0">
<tr>
<td> <br>
<div id="files"></div>
<input type=submit value="提交"/>
<input type=reset value="取消"/> <br> </td>
</tr>
</table>
<form>
<script language="javascript">
<!--
function buildFileInput(obj){
document.getElementById("files").innerHTML=''
for (var i=0;i<obj.value;i++)
document.getElementById("files").innerHTML+='<input id="files"'+i+' type=file><br>'
}//-->
</script>
...
<html:select property="number" name="abc" onchange="buildFileInput()">
<html:option value='1'>1 </html:option>
<html:option value='2'>2 </html:option>
<html:option value='3'>3 </html:option>
<html:option value='4'>4 </html:option>
</html:select> ...
function buildFileInput(){
var selectedValue = document.getElementById("abc").value;
alert(selectedValue);
}
var selectedValue =objSelect.options[objSelect.selectedIndex].text;