有一个文本框,边上有个按钮,点一下按钮,弹出一个窗口,里面全是CheckBox按钮,把这些部分选择后,按“提交”按钮,会关闭本窗口,然后再回到调用的父页面中,并且把选中的人的姓名,全部显示在这个文本框中,格式如:

张三|李四|王王|
选几个人,就显示这些人,用'|'分开.....

temp1.htm

<script language="javascript">
function openwinvote(url,maxh,maxw)
{
var w=500,h=500;
if (maxh!=null) h=maxh;
if (maxw!=null) w=maxw;
var l=(screen.width-w)/2;
var t=(screen.height-h)/2;
window.open

(url,
"new_window","fullscreen2=1;toolbar=0,location=0,directories=0,menubar=0,scrollbars=1,resizable=0,status=0,top="+t+"

,left=
"+l+",width="+w+",height="+h);
}
                                                                                          
</script>
<form id=form1 name=form1 action="temp.asp" target="popwin" onSubmit="window.open('', 'popwin', 'width=610,height=200')">
<div align="center">收件人: 
  
<textarea name="textarea1" cols="50" rows="4" ></textarea>
  
<input type="button" name="Submit" value="选择收件人" onClick="javascript:openwinvote

('temp2.htm',510,500)"
>
</div>
</form>

temp2.htm
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<script>
function retu()
{
var p=window.opener;
var x='';
var obj1=checkdiv1.getElementsByTagName("input");
var obj2=checkdiv2.getElementsByTagName("input");
for(i=0 ;i< obj1.length; i++
{
if(obj1[i].type == "checkbox")
if(obj1[i].checked)
x
+=obj1[i].value+'|';
}

for(i=0 ;i< obj2.length; i++
{
if(obj2[i].type == "checkbox")
if(obj2[i].checked)
x
+=obj2[i].value+'|';
}

p.form1.textarea1.value
=x;
window.close();
}

function check1(obj)
{
var c=checkdiv1.getElementsByTagName("input");
for(i=0 ;i< c.length; i++
if(c[i].type.toLowerCase() == "checkbox")
c[i].checked
=obj.checked;
}

function check2(obj)
{
var c=checkdiv2.getElementsByTagName("input");
for(i=0 ;i< c.length; i++
if(c[i].type.toLowerCase() == "checkbox")
c[i].checked
=obj.checked;
}

</script>
<body>
<table width="100%" border="0" cellpadding="1" cellspacing="1">
  
<tr> 
    
<td height="23"><font color="#FF0000"><strong>语文组</strong></font><strong></strong> 
      
<input type="checkbox" name="checkbox" value="语文组" onclick="check1(this)">
      本组全选
</td>
  
</tr>
  
<tr> 
    
<td>
<table id=checkdiv1 align="center">
<tr>
<td height="23"> 
        
<input type="checkbox" name="checkbox2" value="张三">
        张三 
        
<input type="checkbox" name="checkbox3" value="李四">
        李四 
        
<input type="checkbox" name="checkbox4" value="小二">
        小二 
        
<input type="checkbox" name="checkbox5" value="大哥">
        大哥
</td>
  
</tr>
  
<tr> 
    
<td height="23">
        
<input type="checkbox" name="checkbox23" value="张三1">
        张三1 
        
<input type="checkbox" name="checkbox33" value="李四1">
        李四1 
        
<input type="checkbox" name="checkbox43" value="小二1">
        小二1 
        
<input type="checkbox" name="checkbox53" value="大哥1">
        大哥1
</td>
  
</tr>
  
<tr> 
    
<td height="23"> 
        
<input type="checkbox" name="checkbox24" value="张三2">
        张三2 
        
<input type="checkbox" name="checkbox34" value="李四2">
        李四2 
        
<input type="checkbox" name="checkbox44" value="小二2">
        小二2
        
<input type="checkbox" name="checkbox54" value="大哥2">
        大哥2
</td>
  
</tr>
  
<tr> 
    
<td height="23">
        
<input type="checkbox" name="checkbox24" value="张三3">
        张三3 
        
<input type="checkbox" name="checkbox34" value="李四3">
        李四3 
        
<input type="checkbox" name="checkbox44" value="小二3">
        小二3 
        
<input type="checkbox" name="checkbox54" value="大哥3">
        大哥3
</td>
  
</tr>
  
<tr> 
    
<td height="23"> 
        
<input type="checkbox" name="checkbox24" value="张三4">
        张三4 
        
<input type="checkbox" name="checkbox34" value="李四4">
        李四4 
        
<input type="checkbox" name="checkbox44" value="小二4">
        小二4 
        
<input type="checkbox" name="checkbox54" value="大哥4">
        大哥4
</td>
  
</tr>
</table>
</td>
</tr>
  
<tr> 
    
<td height="23"><strong><font color="#FF0000">数学组:</font></strong> <input type="checkbox" name="checkbox6" value="本

组全选"
 onclick="check2(this)">
      本组全选
</td>
  
</tr><div>
  
<tr> 
    
<td>
<table id=checkdiv2 align="center">
<tr>
<td height="23">  
        
<input type="checkbox" name="checkbox22" value="王丽">
        王丽 
        
<input type="checkbox" name="checkbox32" value="赵雪">
        赵雪 
        
<input type="checkbox" name="checkbox42" value="关爱娟">
        关爱娟 
        
<input type="checkbox" name="checkbox52" value="洪菲">
        洪菲
</td>
  
</tr>
  
<tr> 
    
<td height="23"> 
        
<input type="checkbox" name="checkbox22" value="王丽1">
        王丽1 
        
<input type="checkbox" name="checkbox32" value="赵雪1">
        赵雪1 
        
<input type="checkbox" name="checkbox42" value="关爱娟1">
        关爱娟1 
        
<input type="checkbox" name="checkbox52" value="洪菲1">
        洪菲1
</td>
  
</tr>
  
<tr> 
    
<td height="23"> 
        
<input type="checkbox" name="checkbox22" value="王丽2">
        王丽2 
        
<input type="checkbox" name="checkbox32" value="赵雪2">
        赵雪2 
        
<input type="checkbox" name="checkbox42" value="关爱娟2">
        关爱娟2 
        
<input type="checkbox" name="checkbox52" value="洪菲2">
        洪菲2
</td>
  
</tr>
  
<tr> 
    
<td height="23">
        
<input type="checkbox" name="checkbox22" value="王丽3">
        王丽3 
        
<input type="checkbox" name="checkbox32" value="赵雪3">
        赵雪3 
        
<input type="checkbox" name="checkbox42" value="关爱娟3">
        关爱娟3 
        
<input type="checkbox" name="checkbox52" value="洪菲3">
        洪菲3
</td>
  
</tr>
  
<tr> 
    
<td height="23">
        
<input type="checkbox" name="checkbox22" value="王丽4">
        王丽4 
        
<input type="checkbox" name="checkbox32" value="赵雪4">
        赵雪4 
        
<input type="checkbox" name="checkbox42" value="关爱娟4">
        关爱娟4 
        
<input type="checkbox" name="checkbox52" value="洪菲4">
        洪菲4
</td>
  
</tr>
</table>
</td>
  
</tr>
  
<tr> 
    
<td height="23">&nbsp;</td>
  
</tr>
  
<tr> 
    
<td height="23"><input type="checkbox" name="checkbox7" value="所有全选" onclick="check1(this);check2(this);"> 
      
<font color="#FF0000">所有全选</font>              
      
<input type="submit" name="Submit" value="提交" onclick="retu()"></td>
  
</tr>
  
<tr> 
    
<td height="23">&nbsp;</td>
  
</tr>
</table>
</body>
</html>
posted on 2007-12-06 15:47  miao~  阅读(476)  评论(0编辑  收藏  举报