获得select标签的value值和lable页签值的方法

来源:互联网 发布:广联达钢结构详图软件 编辑:程序博客网 时间:2024/06/07 16:38

 

获得select标签的value值和lable页签值的方法:

<%@ page contentType="text/html; charset=gb2312" language="java"
 import="java.sql.*" errorPage="" pageEncoding="UTF-8"%>

<html>
 <%@ include file="../../FrameWork/jsp/head.jsp"%>
 <script type="text/javascript">
 var selectRb = '';
  function closeWin(){
   //alert('ssss');
   self.close();
   self.opener.focus();
  }
  
function change(ctmid,ctmname,ctmaddress,ctmtel,lkIdindex,ctmtypename)
  {
 // alert('change!!!');
 selectRb = lkIdindex;
 document.thtPsbForm.ID.value=ctmid;
 // alert('ctmid:'+ctmid);
 document.thtPsbForm.ID.ename=ctmname;
 document.thtPsbForm.ID.address=ctmaddress;
 document.thtPsbForm.ID.tel=ctmtel;
 var linkmanid = 'lxrid'+lkIdindex;
 //alert('linkmanid: '+linkmanid);
 var obj = document.getElementById(linkmanid);
 for(i=0;i<obj.length;i++){
  if(obj[i].selected==true)
  {
   //alert('obj.value: '+obj[i].value);---获得option的value值
   //alert('obj.innerText: '+obj[i].innerText);---获得option的lable文本
   document.thtPsbForm.ID.linkmanMc=obj[i].innerText;
   document.thtPsbForm.ID.linkmanId=obj[i].value;
  }
 }
 document.thtPsbForm.ID.ctmtypename=ctmtypename;
}
 
  function selectok(){
   //alert('选择完毕!!');
    self.opener.document.all["thtPsbvo.khDm"].value=thtPsbForm.ID.value;

    self.opener.document.thtPsbForm.CTM_NAME.value=thtPsbForm.ID.ename;//订货单位
    self.opener.document.thtPsbForm.ADDRESS_X.value=thtPsbForm.ID.address;//通讯地址
    self.opener.document.all["LINKMANMC"].value=thtPsbForm.ID.linkmanMc;//联系人名称
        self.opener.document.all["thtPsbvo.khLxr"].value=thtPsbForm.ID.linkmanId;//联系人Id
 self.opener.document.thtPsbForm.LINKTEL_X.value=thtPsbForm.ID.tel;//电话
    self.opener.document.all("thtPsbvo.yyly").value=thtPsbForm.ID.ctmtypename;//产品应用领域
    self.close();
    self.opener.focus();
   
 }
 
 function changeLm(lkIdindex){
 //alert('linkmanid: ');
  if(selectRb == lkIdindex){
   var linkmanid = 'lxrid'+lkIdindex;
 
    var obj = document.getElementById(linkmanid);

    for(i=0;i<obj.length;i++){
      if(obj[i].selected==true)
       {
       //alert('obj.value: '+obj[i].value);---获得option的value值
       //alert('obj.innerText: '+obj[i].innerText);---获得option的lable文本
       document.thtPsbForm.ID.linkmanMc=obj[i].innerText;
       document.thtPsbForm.ID.linkmanId=obj[i].value;
      }
    }
  }
 }
  
 </script>
 <style type="text/css">
<!--
.style1 {color: #FF0000}
-->
</style>

 <body>
  <html:form action="thtPsbAction.do" method="post">
   <table width="100%" border="0" cellspacing="0" cellpadding="0"
    align="center">
    <tr>
     <td>
      <table align="center">
       <tr>
        <td class="tabletitle">
         客户查询
        </td>
       </tr>
      </table>
     </td>
    </tr>
    <tr>
     <td>
      <table width="83%" align="center">
       <tr align="center" class="tableHeader" height="28">
        <td width="13%">
         选择
        </td>
        <td width="16%">
         客户名称
        </td>
        <td width="12%">
         地址
        </td>
        <td width="11%">
         电话
        </td>
        <td width="12%">
         联系人
        </td>
        <td width="24%">
         客户类型
        </td>

       </tr>

       <logic:iterate id="element" name="clients"
        type="com.czkj.web.khgl.customer.TKhcustomerVO" indexId="index">
        <tr class="tableMain">
         <td width="13%">
          <input type="radio" name="radiobutton"
           onClick="change('<bean:write name="element" property="khDm"/>','<bean:write name="element" property="mc"/>','<bean:write name="element" property="address"/>','<bean:write name="element" property="phone"/>','<bean:write name="index" />','<bean:write name="element" property="cmtypemc"/>')">

         </td>
         <td width="16%">
          <bean:write name="element" property="mc" />
         </td>
         <td width="12%">
          <bean:write name="element" property="address" />
         </td>
         <td width="11%">
          <bean:write name="element" property="phone" />
         </td>
         <td width="12%">

          <select style="width:70px" id="lxrid<%=index%>"
           onchange="changeLm('<bean:write name="index" />')">
           <%
              String[] lxrmc = element.getLxrMc();
              String[] lxrid = element.getLxrId();
              for (int i = 0; i < lxrmc.length; i++) {
           %>
           <option value="<%=lxrid[i]%>">
            <%=lxrmc[i]%>
           </option>
           <%
           }
           %>
          </select>
         </td>
         <td width="24%">
          <bean:write name="element" property="cmtypemc" />
         </td>

        </tr>
       </logic:iterate>

       <tr class="page">
        <td colspan="6">
         <div align="center">
          分页区或备注说明区
         </div>
        </td>
       </tr>

      </table>

     </td>
    </tr>

 

    <tr>
     <td align="center">
      <table>
       <tr>

        <td class="sparator2">
        </td>
       </tr>
       <tr>

        <td align="center" class="buttonTable2">
         <input type="button" class="button"
          onMouseOver="this.className='buttononMouseOver'"
          onMouseDown="this.className='buttononMouseDown'"
          onMouseOut="this.className='buttononMouseOut'"
          onclick="javascript:selectok();" value="选择完毕">
         <input type="button" class="button"
          onMouseOver="this.className='buttononMouseOver'"
          onMouseDown="this.className='buttononMouseDown'"
          onMouseOut="this.className='buttononMouseOut'"
          onclick="javascript:closeWin();" value="放弃">
        </td>
       </tr>
      </table>
     </td>
    </tr>
    <input type="hidden" name="ID" value="" ename="" address="" tel=""
     linkmanMc="" linkmanId="" bank="" account="" taxcode="" fax=""
     chairman="" postcode="" ctmtypename="">

   </table>
  </html:form>

 </body>

</html>
 

原创粉丝点击