Home  >  Article  >  Web Front-end  >  Web page passes the value from the pop-up page radio button to the parent page code sharing_javascript skills

Web page passes the value from the pop-up page radio button to the parent page code sharing_javascript skills

WBOY
WBOYOriginal
2016-05-16 15:37:361557browse

In the project, it is necessary to complete such a function: when joining a new organization, it needs to select its parent organization. The implementation method is to click the search and fill button, a pop-up page will pop up, the user clicks on the required row, and clicks Click the OK button to return the user-selected institution name and institution code to the page for joining a new institution.

Record the pop-up page code here

<!DOCTYPE html PUBLIC "-//WC//DTD HTML . Transitional//EN" "http://www.w.org/TR/html/loose.dtd">
 <%@ page contentType="text/html;charset=utf-" pageEncoding="utf-" language="java" %>
 <%@ taglib uri="/struts-tags" prefix="s"%>
 <%@ taglib uri="/page-tags" prefix="p"%>
 <html>
   <head>
     <title>机构点选查询</title>
     <meta http-equiv="Content-Type" content="text/html; charset=utf-">
     <link rel="stylesheet" type="text/css" href="../css/style.css" />
     <link rel="stylesheet" type="text/css" href="../css/newStyle.css" />
     <script type="text/javascript" src="../js/jquery.js"></script>
     <script type="text/javascript" src="../js/common.js"></script>
     <script type="text/javascript" charset="utf-">
 //点击整行都可选中单选框
     function clickTr(obj) {
     $("#mainTable tbody tr td input[type='radio']").attr("checked",
         "undefined");
     $("td input[type='radio']", obj).attr("checked", "checked");
     //alert($("td input[name='insideEquip.equipinstance']",obj).val());
   }
 //将通过td的class获取到的值传到父页面对应的元素上
   function setValue() {
     var input = $("#mainTable tbody tr td input[type='radio']:checked");
     if (!input.val()) {
 
       window.close();
       return;
     }
     var tr = input.parent().parent();
     
     window.opener.document.getElementById("textagencyid").value = $(
         "td.agancy input", tr).val();
     window.opener.document.getElementById("textagencyname").value = $(
         "td.agencyname", tr).text();
     
     window.close();
   }  
   </script>
   </head>
   <body>
 <div class="searchArea" style="height:px;">
 <form action="" method="post">
     <input class="button" type="button" value="确定" onclick="javascript:setValue();"/>
     </form>
   </div>
    <div class="tableArea">
   <table class="mainTable" id="mainTable">
     <thead>
     <tr>
               <th>选择</th>
               <th>机构编号</th>
               <th>机构名称</th>
               <!--<th>工作岗位码</th>-->
               <th>上级机构</th>
               <th>组织机构代码</th>
               <th>机构类别</th>        
     </tr>
     </thead>
     <tbody>  
    <s:iterator value="busiAgencys" var="p" >
     <tr onclick="clickTr(this);">
     <td class="agancy"><input type="radio" name="log" value="<s:property value="agencyid"/>" ></td>
     <td><s:property value="agencyid"/></td>
     <td class="agencyname"><s:property value="agencyname"/></td>
     <!--<td><s:property value="handle"/></td>-->
     <td><s:property value="sjjg"/></td>
     <td><s:property value="orgcode"/></td>
     <td><s:property value="jglb"/></td>
    </tr>
    </s:iterator>    
     </tbody>
   </table>
   <div class="pagin">
     <p:page href="findBusiAgency" css="pages" totalPage="${totalPage}" page="${page}"></p:page>
   </div>  
   </div>
   <script type="text/javascript">
   $('.tablelist tbody tr:odd').addClass('odd');
   </script>
   </body>
 </html>

The above code is very simple. Friends who need it can copy it directly. I hope the above content will be helpful to everyone.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn