父页:send_message.jsp
- <script language=javascript type="">
- //open win
- function g_OpenWindow(pageURL, innerWidth, innerHeight)
- {
- var ScreenWidth=screen.availWidth
- var ScreenHeight=screen.availHeight
- var StartX=(ScreenWidth-innerWidth)/2
- var StartY=(ScreenHeight-innerHeight)/2
- var wins=window.open(pageURL,'OpenWin','left='+StartX+',top='+StartY+',Width='+innerWidth+',height='+innerHeight+',resizable=yes,scrollbars=yes,status=no,toolbar=no,menubar=no,location=no')
- wins.focus();
- }
- </script>
- <body>
- <table width=90% cellpadding="1" cellspacing="1" align="center">
- <tr><td colspan=4 align="left" class="td1">
- <font color="#2E75BB"><b>NCSB站内邮件系统</b></font><p></td></tr>
- </table>
- <form action="send.jsp" name="mail" id="mail">
- <table width="80%" cellpadding="1" cellspacing="5" align="center" >
- <tr><td colspan="2"><img alt="写新邮件" src="../img/tp009.gif" /> <font color="blue">写新邮件</font></td>
- </tr>
- <tr><td colspan="2"><hr size="1" width="82%" align="left"/></td>
- </tr>
- <tr><td>收件人:</td><td><input name="receive" id="receive" type="text" size="10" readonly="readonly"/> <input type="button" name="selectcaizhi" value="收件人列表" onClick="g_OpenWindow('list.jsp','680','400')" class="submit"></td>
- </tr>
- <tr><td>主题:</td><td><input name="title" type="text" size="10"/></td>
- </tr>
- <tr><td>内容:</td><td><textarea cols="61" rows="10"></textarea></td>
- </tr>
- <tr align="center"><td colspan="2"><br /><input type=reset align="middle" value=" 重 设 " class="submit" size="10">
- <input type=submit value=" 发 送 " size="10" align="middle" name="" class="submit"></td>
- </tr>
- </table>
- </form>
- </body>
子页:list.jsp 如果返回checkbox的值为单一值则直接赋给父表单,如果为多值则以“,”间隔联结成为字符串赋值
- <script language=javascript type="">
- function Select(){
- var addstr = "";
- var chb = document.getElementsByName("receiver");
- for(i=0;i<chb.length;i++)
- {
- if(chb[i].checked)
- {
- if(i==0)
- {
- addstr = chb[i].value;
- }
- else
- {
- addstr += "," + chb[i].value
- }
- }
- }
- window.opener.document.getElementById("receive").value =addstr;
- self.close();
- }
- </script>
- <body>
- <form action="#" method="POST" name="s_form" id="s_form" onsubmit="return Select();">
- <table align="center">
- <tr><td colspan="5"><font color="blue"><b>NCSB系统用户列表</b></font></td>
- </tr>
- <%
- Connection con=null;
- try{
- con=DBConnection.getConnection();
- PreparedStatement pStmt=con.prepareStatement("select * from users order by department");
- ResultSet rs=pStmt.executeQuery();
- int a=0;
- while(rs.next()){//每5条记录为一行显示
- if(a==0){%><tr><td><input type="checkbox" id="receiver" value="<%=rs.getString("username").trim()%>" name="receiver"/><%=rs.getString("realname")%>(<%=rs.getString("department")%>)</td>
- <%a++;}else if(a>0&&a<4){%><td><input type="checkbox" id="receiver" value="<%=rs.getString("username").trim()%>" name="receiver"/><%=rs.getString("realname")%>(<%=rs.getString("department")%>)</td>
- <%a++;}else{%><td><input type="checkbox" id="receiver" value="<%=rs.getString("username").trim()%>" name="receiver"/><%=rs.getString("realname")%>(<%=rs.getString("department")%>)</td></tr>
- <%a=0;}%>
- <%}
- con.close();
- rs.close();
- }catch(Exception e){
- e.printStackTrace();
- }
- %>
- <tr align="right"><td colspan="5">
- <input type=reset align="middle" value="重设" class="submit" size="10">
- <input type=submit value="确定" size="10" align="middle" name="" class="submit""></td>
- </tr>
- </table>
- </form>
- </body>
新闻热点
疑难解答