`
阿_剛
  • 浏览: 9198 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

通过Text 来设定 Select Option 缺省值

阅读更多
<%@page language="java" contentType="text/html; charset=UTF-8"  pageEncoding="UTF-8"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title></title>
<link rel="stylesheet" type="text/css" href="${f:url('/css/stylesheet.css')}">
<script type="text/javascript">

function add(btn) {
   btn.disabled = true;
   var frm = document.getElementById("form1");
   frm.action += "add";
   frm.submit();
}

function change(){
if (event.keyCode == 13){
alert("文字が「" + Myfm.txt.value +"」に変更されました");
}
else
return
}

function SetdefaultData(textObj,selectObj){
for(i=0;selectObj.length>i;i++){
<%--alert(frmObj.elements["deptId_test"].value);--%>
if(selectObj.options[i].value == textObj.value){
selectObj.options[i].selected = true;
<%--alert("ttt"+f.options.value);--%>
break;
}else{
selectObj.options[0].selected = true;
}
}
}



</script>
</head>
<body>
<s:form method="POST" styleId="form1">
<tiles:insert template="/WEB-INF/view/common/layout.jsp" flush="true">
<tiles:put name="content_menu" type="string">
<c:choose>
   <c:when test="${id == null}">
       <button onclick="add(this)">登録</button>
   </c:when>
   <c:otherwise>
       <s:submit property="update" value="更新"/>
   </c:otherwise>
</c:choose>
</tiles:put>
<tiles:put name="content" type="string">
<div id="content" class="content_scroll">
   <html:errors/>
       <table class="data" style="width:300px;">
       <tr>
           <th class="data" style="width: 100px;">ID</th>
           <td class="data" style="width:150px;">
           ${id}<html:hidden property="id"/><html:hidden property="versionNo"/>
           </td>
       </tr>
       <tr>
           <th class="data">従業員番号</th>
           <td class="data">
               <html:text property="empNo" size="12" maxlength="10" errorStyleClass="error"/></td>
       </tr>
       <tr>
           <th class="data">従業員名</th>
           <td class="data">
               <html:text property="empName" size="26" maxlength="20" errorStyleClass="error"/></td>
       </tr>
       <tr>
           <th class="data">雇用日</th>
           <td class="data">
               <html:text property="hiredate" size="12" maxlength="10" errorStyleClass="error"/>
           </td>
       </tr>
       <tr>
           <th class="data">給与</th>
           <td class="data">
               <html:text property="sal" size="10" maxlength="8" errorStyleClass="error"/>
           </td>
       </tr>
       <tr>
           <th class="data">管理者ID</th>
           <td class="data">
               <html:text property="mgrId" size="12" maxlength="10" errorStyleClass="error"/>
           </td>
       </tr>
       <tr>
           <th class="data">部門名</th>
           <td class="data">
               <html:select property="deptId">
                   <option value=""></option>
                   <html:options collection="deptList" property="id" labelProperty="deptName"/>
               </html:select>
           </td>
           <html:text property="deptId_test" size="12" maxlength="10" onkeydown="SetdefaultData(this.form.elements['deptId_test'],document.getElementById('testID'))" onkeyup="SetdefaultData(this.form.elements['deptId_test'],document.getElementById('testID'))"/>
       </tr>
      
       <tr>
           <th class="data">SELECT OPTION</th>
           <td class="data">
               <html:select property="testID">
                   <option value="C"></option>
                   <html:options collection="testList" property="KeyData" labelProperty="ValData"/>
               </html:select>
           </td>
          
       </tr>
       </table>
       <html:hidden property="versionNo"/>
</div>
</tiles:put>
</tiles:insert>
</s:form>
</body>
</html>
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics