我正在研究一个邮件群发问题,在选择多个收件人的问题上遇到了麻烦,请各位达人指导一下,多谢.
我做的一个小例子如下.
1.asp //此页面为发邮件页面.即获取收件人页面.
<form name="form1" method="post" action="">
<input type="text" name="text1">
<a href="javascript:void(null)" class="add" onClick="open('3.asp','','resizable=1,scrollbars=0,status=no,toolbar=no,menu=no,width=580,height=400,left=150,top=50')">增加</a>
</form>
3.asp //此页面为收件人选择页面,是由1.asp页面上的增加触发的弹出页面.
<script language="JavaScript">
function copyToList(from,to) //from表示:包含可选择项目的select对象名字 to表示:列出可选择项目的select对象名字
//你可以根据你的具体情况修改
{
fromList = eval('document.forms[0].' + from);
toList = eval('document.forms[0].' + to);
if (toList.options.length > 0 && toList.options[0].value == 'temp')
{
toList.options.length = 0;
}
var sel = false;
for (i=0;i<fromList.options.length;i++)
{
var current = fromList.options[i];
if (current.selected)
{
sel = true;
if (current.value == 'temp')
{
alert ('你不能选择这个项目!');
return;
}
txt = current.text;
val = current.value;
toList.options[toList.length] = new Option(txt,val);
fromList.options[i] = null;
i--;
}
}
}
function allSelect() //这是当用户按下提交按钮时,对列出选择的select对象执行全选工作,让递交至的后台程序能取得相关数据
{
List = document.forms[0].chosen;
if (List.length && List.options[0].value == 'temp') return;
for (i=0;i<List.length;i++)
{
List.options[i].selected = true;
}
}
function copyAll(from,to){var fromList = eval('document.forms[0].' + from);
var toList = eval('document.forms[0].' + to);
if (toList.options.length > 0 && toList.options[0].value == 'temp')
{
toList.options.length = 0;
}
for (i=0;i<fromList.options.length;i++)
{
var current = fromList.options[i];
toList.options[toList.length] = new Option(current.text,current.value);
fromList.options[i] = null;
i--;
}
}function returnValue()
{
window.opener.document.all.text1.value=document.getElementById("chosen").value + ",";
window.close();
}
</script>
<table border="0"> <form onSubmit="allSelect()">
<tr>
<td>
<select name="possible" size="4"
MULTIPLE width=200 style="width: 200px">
<option value="中国广州">中国广州
<option value="中国上海">中国上海
<option value="中国北京">中国北京
<option value="中国武汉">中国武汉
</select>
</td>
<td><div align="center"><a href="javascript:copyToList('possible','chosen')">选择></a><br>
<br>
<a href="javascript:copyAll('possible','chosen')">全选>></a>
<br>
<br>
</a><a href="javascript:copyToList('chosen','possible')"><删除</a><br>
<br>
</a><a href="javascript:copyAll('chosen','possible')"><<重置</a>
<br>
</div></td>
<td>
<select name="chosen" size="4"
MULTIPLE width=200 style="width: 200px;">
<option value="temp">从左边选择你的地区
</select>
</td>
</tr>
<tr><input type="button" name="Submit" value="提交" onClick="returnValue();"></tr></form>
</table>我想实现的是通过点击3.asp中的提交按钮,把后面列表框中选中的所有项都提交到1.asp页面中的文本框中,并且每项中间以逗号隔开,然后在生成邮件时按人名分别存入数据库.
现在我的问题是我通过点击3.asp中的提交按钮,在没有选择后面列表框中值的情况下不能获取值,就算全选了后面列表框中的值,在1.asp中也只能获取到第1项的值,麻烦各位达人指教.多谢.
我做的一个小例子如下.
1.asp //此页面为发邮件页面.即获取收件人页面.
<form name="form1" method="post" action="">
<input type="text" name="text1">
<a href="javascript:void(null)" class="add" onClick="open('3.asp','','resizable=1,scrollbars=0,status=no,toolbar=no,menu=no,width=580,height=400,left=150,top=50')">增加</a>
</form>
3.asp //此页面为收件人选择页面,是由1.asp页面上的增加触发的弹出页面.
<script language="JavaScript">
function copyToList(from,to) //from表示:包含可选择项目的select对象名字 to表示:列出可选择项目的select对象名字
//你可以根据你的具体情况修改
{
fromList = eval('document.forms[0].' + from);
toList = eval('document.forms[0].' + to);
if (toList.options.length > 0 && toList.options[0].value == 'temp')
{
toList.options.length = 0;
}
var sel = false;
for (i=0;i<fromList.options.length;i++)
{
var current = fromList.options[i];
if (current.selected)
{
sel = true;
if (current.value == 'temp')
{
alert ('你不能选择这个项目!');
return;
}
txt = current.text;
val = current.value;
toList.options[toList.length] = new Option(txt,val);
fromList.options[i] = null;
i--;
}
}
}
function allSelect() //这是当用户按下提交按钮时,对列出选择的select对象执行全选工作,让递交至的后台程序能取得相关数据
{
List = document.forms[0].chosen;
if (List.length && List.options[0].value == 'temp') return;
for (i=0;i<List.length;i++)
{
List.options[i].selected = true;
}
}
function copyAll(from,to){var fromList = eval('document.forms[0].' + from);
var toList = eval('document.forms[0].' + to);
if (toList.options.length > 0 && toList.options[0].value == 'temp')
{
toList.options.length = 0;
}
for (i=0;i<fromList.options.length;i++)
{
var current = fromList.options[i];
toList.options[toList.length] = new Option(current.text,current.value);
fromList.options[i] = null;
i--;
}
}function returnValue()
{
window.opener.document.all.text1.value=document.getElementById("chosen").value + ",";
window.close();
}
</script>
<table border="0"> <form onSubmit="allSelect()">
<tr>
<td>
<select name="possible" size="4"
MULTIPLE width=200 style="width: 200px">
<option value="中国广州">中国广州
<option value="中国上海">中国上海
<option value="中国北京">中国北京
<option value="中国武汉">中国武汉
</select>
</td>
<td><div align="center"><a href="javascript:copyToList('possible','chosen')">选择></a><br>
<br>
<a href="javascript:copyAll('possible','chosen')">全选>></a>
<br>
<br>
</a><a href="javascript:copyToList('chosen','possible')"><删除</a><br>
<br>
</a><a href="javascript:copyAll('chosen','possible')"><<重置</a>
<br>
</div></td>
<td>
<select name="chosen" size="4"
MULTIPLE width=200 style="width: 200px;">
<option value="temp">从左边选择你的地区
</select>
</td>
</tr>
<tr><input type="button" name="Submit" value="提交" onClick="returnValue();"></tr></form>
</table>我想实现的是通过点击3.asp中的提交按钮,把后面列表框中选中的所有项都提交到1.asp页面中的文本框中,并且每项中间以逗号隔开,然后在生成邮件时按人名分别存入数据库.
现在我的问题是我通过点击3.asp中的提交按钮,在没有选择后面列表框中值的情况下不能获取值,就算全选了后面列表框中的值,在1.asp中也只能获取到第1项的值,麻烦各位达人指教.多谢.
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货