Html中select及Jsp中调用

来源:百度知道 编辑:UC知道 时间:2024/05/21 11:45:32
html中定义输入框
<INPUT TYPE="text" NAME="txtAcNo" SIZE="20">
在jsp中调用输入框的值
String actNumber = request.getParameter("txtAcNo");
但是在html中定义选择框的代码不知道正确不?而且希望高人帮我写一些掉用选择框中几个值的方法。并且要判断这些值 =管理员 或=燃煤管理 等怎么写。谢谢你的帮助。
<select name="user_role" id="user_role">
<option selected="selected">燃煤管理</option>
<option>燃油管理</option>
<option>消耗管理</option>
<option>管理员</option>
</select>

<option>标签中有个value属性,你把每个选项的value属性设置一下,
然后用getparameter("user_role")获取、

最后你只需要比较一下就OK啦

<select name="user_role" id="user_role">
<option selected="selected" value="rangmei">燃煤管理</option>
<option value="rangyou">燃油管理</option>
<option value="xiaohaoManage">消耗管理</option>
<option value="manager">管理员</option>
</select>

if("rangmeiManage".equals(request.getparameter("user_role")){
....
}else if("rangyouManage".equals(request.getparameter("user_role")){
...
}else if(...){
...
}

<select name="user_role" id="user_role">
<option selected="selected" value="燃煤管理">燃煤管理</option>
<option value="燃油管理">燃油管理</option>