动态设置select与radio的默认值
2011-10-07 23:29
447 查看
<%@ page language="java" import="java.util.*,isa.model.PersonBean" contentType="text/html;charset=gb2312" pageEncoding="gb2312"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <title>My JSP 'personmu.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> <script language= JavaScript> function check() { var id=document.form1.id.value; var name=document.form1.name.value; if(id==""){ alert("对不起,会员号不能为空"); return false; }else if(name==""){ alert("对不起,姓名不能为空"); return false; } else { return true; } } function initradio(rName,rValue){ var rObj = document.getElementsByName(rName); for(var i = 0;i < rObj.length;i++){ if(rObj[i].value == rValue){ rObj[i].checked = 'checked'; } } } </script> </head> <body bgcolor="#ccffff"> <% //防止用户非法登录 String u=(String)session.getAttribute("id"); String l=(String)session.getAttribute("level"); if(u==null){ response.sendRedirect("login.jsp?err=1"); return; } //要显示的信息从Request中取 PersonBean pb=(PersonBean)request.getAttribute("result"); %> <table width="400" border="0" align="center" cellpadding="0" cellspacing="0" height="250px"> <tr> <td scope="row" width="450"> <form id="form1" name="form1" onsubmit="return check()" method="post" action="PersonMUServlet"> <table width="400" align="center" > <tr> <td height="30" colspan="2"><div align="center">会 员 管 理</div></td> </tr> <tr> <td width="150" height="30" align="right">刚果号:</td> <td width="250" align="left"> <input type="text" name="id" value="<%=pb.getpId() %>" readonly="readonly" maxlength="16" size="24"/> </td> </tr> <tr> <td width="150" height="30" align="right">姓 名:</td> <td width="250" align="left"> <input type="text" name="name" value="<%=pb.getpName() %>" maxlength="16" size="24"/> </td> </tr> <tr> <td width="150" height="30" align="right">部 门:</td> <td width="250" align="left"> <input type="text" name="dept" readonly="readonly" value="<%=pb.getdNo() %>" maxlength="16" size="24"/> </td> </tr> <tr> <td width="150" height="30" align="right"> 小 组:</td> <td width="250" align="left"> <input type="text" name="team" readonly="readonly" value="<%=pb.gettNo() %>" maxlength="16" size="24"/> </td> </tr> <tr> <td width="150" height="30" align="right">职 务:</td> <td width="250" align="left"> <select name="job" size="1" > <option value="普通会员">普通会员</option> <option value="副组长">副组长</option> <option value="组长">组长</option> <option value="主任">主任</option> <option value="副部长">副部长</option> <option value="部长">部长</option> <option value="秘书长">秘书长</option> <option value="副会长">副会长</option> <option value="会长">会长</option> </select> <!-- 动态设置Select的默认值 --> <script language= JavaScript> var job= "<%=pb.getJob() %>"; document.getElementsByName("job")[0].value=job; </script> </td> </tr> <tr> <td width="150" height="30" align="right">专 业:</td> <td width="250" align="left"> <input type="text" name="speciality" value="<%=pb.getSpeciality() %>" size="24" maxlength="24"/> </td> </tr> <tr> <td width="150" height="30" align="right">性 别:</td> <td width="250" align="left"> <input name="sex" type="radio" value="男" checked="checked" />男 <input type="radio" name="sex" value="女" />女 <!-- 动态设置radio的默认值 --> <script language= JavaScript> var s="<%=pb.getSex() %>"; initradio('sex',s); </script> </td> </tr> <tr> <td width="150" height="30" align="right">电 话:</td> <td width="250" align="left"> <input type="text" name="tel" value="<%=pb.getTel() %>" maxlength="15" size="24"/> </td> </tr> <tr> <td colspan="2" width="400" height="30" align="center"> <input type="submit" name="submit" value="提交" /> </td> </tr> </table> </form> </td> </tr> </table> </body> </html>
相关文章推荐
- 动态设置select与radio的默认值
- 动态设置select默认值代码
- 关于动态图片轮播以及图片显示的问题以及提示代码是死的,和重定向的时候传递值得问题,以及s:select和s:radio的传值以及默认值和回显的问题
- js动态设置select的默认值
- 动态设置radio的默认值
- 动态给option设置selected后,select下拉框显示不正确,未显示默认值
- 使用JS动态设置select的默认值
- js中动态设置select中option选中/设置radio选中/获取textarea值
- 【Angular】select标签,ng-options标签中,下拉列表动态查询,默认值为空;
- jQuery textbox select checkbox radio 取值,设置值
- 如何给报表参数设置动态默认值
- RadioGroup动态添加RadioButton,RadioButton设置默认选中第一个,点击其他的RadioButton第一个不再选中,第一个不再选中
- select2 多选设置默认值
- Angular2 select用法-设置默认值和事件
- 设置select组件中的默认值
- select标签 selected 选中状态动态设置
- js_前台页面如何设置radio、checkbox、select三者的值以及绑定事件,方便后台接收数据
- jQuery设置 select、radio、checkbox 默认选中的值
- 如何设置select-option的多项起始默认值
- doubleselect标签的默认值设置