<script language=javascript>
function selstr(){
selstr="";
var options = document.sendtbl.seltbl.options;
for(var j=0;j<options.length;j++)
{
if(options[j].selected)
selstr=selstr + options[j].value + ","
}document.sendtbl.seloptions.value=selstr; return true;
}</script><form action="1.asp" method="post" name="sendtbl" id="sendtbl" onsubmit="return selstr()">
function selstr(){
selstr="";
var options = document.sendtbl.seltbl.options;
for(var j=0;j<options.length;j++)
{
if(options[j].selected)
selstr=selstr + options[j].value + ","
}document.sendtbl.seloptions.value=selstr; return true;
}</script><form action="1.asp" method="post" name="sendtbl" id="sendtbl" onsubmit="return selstr()">
解决方案 »
- dhtmlxTree样式问题
- 奇怪,document.cookie中cookie的所在目录问题。
- 疯了,高手看看document.getElementById
- 请教碁础概念,history对象的length属性,表示最近访问过的页面个数,"最近访问过"是一个什么概念,如何界定?
- 有没有办法控制alert提示弹出的位置?
- 请问Opera下的有关事件
- top.main.location??
- ExtJS4 请教TreeGrid使用问题
- 如何在进入页面时,焦点定位在<input type="text"> 输入框中呢!
- 很感人的一部mtv:http://music.jzmpg.com/日韩流行/kiss.rar好东西大家分
- javascript问题,非常简单!!
- 在表单各个元素中加入什么标记,判断是否需要进行脚本验证比较好呢?
<form action="1.asp(*页面自身*)" method="post" name="sendtbl" id="sendtbl" onsubmit="return selstr();">
<input type="hidden" name="seloptions">
......
......</form>sendtbl(*表单名称*).seloptions(*表单隐含项名称*).value=selstr因该是document.sendtbl.seloptions.value=selstr;
或者document.forms[0].seloptions.value=selstr;
那我怎样读出选项来呢
具体点好么?
============
<%
dim str
str=request.form("aa")
Response.write str
str=Split(str,",")
for i=LBound(str) to Ubound(str)
Response.write "<hr>"
Response.write str(i)
Next
%>
<form name=f action="form.asp" method="post">
<select name=aa multiple=true>
<option value="a">a</option>
<option value="b">b</option>
<option value="c">c</option>
<option value="d">d</option>
<option value="e">e</option>
</select>
<input onclick="test()" value="get" type=button>
</form>
<SCRIPT>
function test()
{
var str=""for(var i=0;i<document.f.aa.options.length;i++)
{
if(document.f.aa.options[i].selected==true)
str = str + document.f.aa.options[i].value + ","
}alert(str)
document.f.submit()
}
</SCRIPT>
============
<%
dim str
str=request.form("aa")
Response.write str
str=Split(str,",")
for i=LBound(str) to Ubound(str)
Response.write "<hr>"
Response.write str(i)
Next
%>
<form name=f action="form.asp" method="post">
<select name=aa multiple=true>
<option value="a">a</option>
<option value="b">b</option>
<option value="c">c</option>
<option value="d">d</option>
<option value="e">e</option>
</select>
<input onclick="test()" value="get" type=button>
</form>
<SCRIPT>
function test()
{
var str=""for(var i=0;i<document.f.aa.options.length;i++)
{
if(document.f.aa.options[i].selected==true)
str = str + document.f.aa.options[i].value + ","
}alert(str)
document.f.submit()
}
</SCRIPT>
============
<%
dim str
str=request.form("aa")
Response.write str
str=Split(str,",")
for i=LBound(str) to Ubound(str)
Response.write "<hr>"
Response.write str(i)
Next
%>
<form name=f action="form.asp" method="post">
<select name=aa multiple=true>
<option value="a">a</option>
<option value="b">b</option>
<option value="c">c</option>
<option value="d">d</option>
<option value="e">e</option>
</select>
<input onclick="test()" value="get" type=button>
</form>
<SCRIPT>
function test()
{
var str=""for(var i=0;i<document.f.aa.options.length;i++)
{
if(document.f.aa.options[i].selected==true)
str = str + document.f.aa.options[i].value + ","
}alert(str)
document.f.submit()
}
</SCRIPT>
剩下你说的方法我先前也试过,仍然提交不了
按你的方法试了一下,还是不可以,我觉得还是在子函数内部字符串变量提交的问题,就是那句话sendtbl(*表单名称*).seloptions(*表单隐含项名称*).value=selstr 出的问题,应该怎样来写这句话,以提交变量。下面是我子函数的内容:
function selstr(){
selstr=""
for(var j=0;j<sendtbl.seltbl.length;j++)
{
if(document.all.sendtbl.seltbl.options[j].selected)
selstr=selstr+sendtbl.seltbl.options[j].value+","
}
alert(selstr)sendtbl.seloptions.value=selstr
sendtbl.submit()
}</script>不管用的家的什么方法,都可以正确的实现selstr字符串的值,就是
没有办法把这个值通过表单传出去.
下面是我在程序中form中的内容。<form action="qq.asp" method="post" name="sendtbl" id="sendtbl" onsubmit="selstr()">
<table width="80" border="2" cellspacing="0" cellpadding="0" height="145" >
<tr>
<td height="20" width="87%" background="pic/title.gif">
<b><font size="2" face="Ó×Ô²">·¢ËÍÏûÏ¢</font></b></td>
<td height="17" width="13%"><img style="CURSOR: hand" src="pic/closeb.gif" width="17" height="17" onClick="window.close()"></td>
</tr>
<tr bgcolor="buttonface">
<td height="15" colspan="2" bordercolor="buttonface">
<div align="center"> <font face="Ó×Ô²" color="#000000"> Ìîд·¢Ë͵ÄÐÅÏ¢ </font>
</div>
</td>
</tr>
<tr bgcolor="buttonface">
<td height="15" colspan="2" bordercolor="buttonface">
<input type="text" name="title" class=textBox>
</td>
</tr>
<tr bgcolor="buttonface">
<td height="50" colspan="2" bordercolor="buttonface">
<div align="center">
<textarea name="mem" class="textBox" rows="5"></textarea>
</div>
</td>
</tr>
<tr bgcolor="buttonface">
<td height="15" colspan="2" bordercolor="buttonface">
<div align="center"> <font face="Ó×Ô²" color="#000000"> Ñ¡Ôñ·¢ËÍµÄ±íµ¥Ãû³Æ(ctrl) </font>
</div>
</td>
</tr> <tr bgcolor="buttonface">
<td height="30" colspan="2" bordercolor="buttonface">
<div align="center">
<select name=seltbl size=3 multiple>
<% bmid=session("bmid")
sqlt="select * from tblmenu where menukey not like '" & left(bmid,3) & "_000' and menukey like '" & left(bmid,3) &"%'"
set rs0=conn.execute(sqlt)
do while not rs0.eof
%>
<option value="<%=trim(rs0(1))%>"><%=trim(rs0(1))%>
<%
rs0.movenext
loop
rs0.close
%>
</select>
</div>
</td>
</tr>
<tr bgcolor="buttonface">
<td height="15" colspan="2" bordercolor="buttonface">
<div align="center"><font color="#000000">ÃÜÂ룺</font>
<input type="password" name="pwd" class=textBox1>
</div>
</td>
</tr>
<tr bgcolor="buttonface">
<td colspan="2" bordercolor="buttonface">
<div align="center">
<input type="submit" name="Submit" value="发送">
<input type="hidden" name="sendid" value="<%=session("bmid")%>">
<input type="hidden" name="recid" value="<%=yid%>">
<input type="hidden" name="seloptions">
</div>
</td>
</tr>
</table></form>
selstr=""
for(var j=0;j<document.sendtbl.seltbl.options.length;j++)
{
if(document.sendtbl.seltbl.options[j].selected)
selstr=selstr+document.sendtbl.seltbl.options[j].value+","
}
alert(selstr)document.sendtbl.seloptions.value=selstr
document.sendtbl.submit()
}</script>
selstr=""
for(var j=0;j<document.sendtbl.seltbl.options.length;j++)
{
if(document.sendtbl.seltbl.options[j].selected)
selstr=selstr+document.sendtbl.seltbl.options[j].value+","
}
alert(selstr)document.sendtbl.seloptions.value=selstr
document.sendtbl.submit()
}</script>
if(document.all.sendtbl.seltbl.options[j].selected)
两句的写法:for(var j=0;j<document.sendtbl.seltbl.options.length;j++)
if(document.sendtbl.seltbl.options[j].selected)我的代码都是试验过的,你自己拷贝试验了吗???
form.asp
strconn="DSN=byconn;uid=sa;pwd=sa"
set conn = server.createobject("adodb.connection")
conn.open strconn
if request("submit")="" then
yid=request("yid")
if yid<>"" then
yid=left(yid,len(yid)-1)'连续向选定部门发送信息
else
yid=session("yid")
end if
session("yid")=yid
%><html>
<head>
<title>QQ写消息</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="sty.css" type="text/css">
<script language=javascript>
function test()
{
var str=""for(var i=0;i<document.sendtbl.seltbl.options.length;i++)
{
if(document.sendtbl.seltbl.options[i].selected==true)
str = str + document.sendtbl.seltbl.options[i].value + ","
}alert(str)
document.sendtbl.submit()
}
</script>
</head><body leftmargin="0" topmargin="0" scroll=no>
<form action="qq.asp" method="post" name="sendtbl" id="sendtbl">
<table width="80" border="2" cellspacing="0" cellpadding="0" height="145" >
<tr>
<td height="20" width="87%" background="pic/title.gif">
<b><font size="2" face="幼圆">发送消息</font></b></td>
<td height="17" width="13%"><img style="CURSOR: hand" src="pic/closeb.gif" width="17" height="17" onClick="window.close()"></td>
</tr>
<tr bgcolor="buttonface">
<td height="15" colspan="2" bordercolor="buttonface">
<div align="center"> <font face="幼圆" color="#000000"> 填写发送的信息 </font>
</div>
</td>
</tr>
<tr bgcolor="buttonface">
<td height="15" colspan="2" bordercolor="buttonface">
<input type="text" name="title" class=textBox>
</td>
</tr>
<tr bgcolor="buttonface">
<td height="50" colspan="2" bordercolor="buttonface">
<div align="center">
<textarea name="mem" class="textBox" rows="5"></textarea>
</div>
</td>
</tr>
<tr bgcolor="buttonface">
<td height="15" colspan="2" bordercolor="buttonface">
<div align="center"> <font face="幼圆" color="#000000"> 选择发送的表单名称(ctrl) </font>
</div>
</td>
</tr> <tr bgcolor="buttonface">
<td height="30" colspan="2" bordercolor="buttonface">
<div align="center">
<select name=seltbl size=3 multiple>
<% bmid=session("bmid")
sqlt="select * from tblmenu where menukey not like '" & left(bmid,3) & "_000' and menukey like '" & left(bmid,3) &"%'"
set rs0=conn.execute(sqlt)
do while not rs0.eof
%>
<option value="<%=trim(rs0(1))%>"><%=trim(rs0(1))%>
<%
rs0.movenext
loop
rs0.close
%>
</select>
</div>
</td>
</tr>
<tr bgcolor="buttonface">
<td height="15" colspan="2" bordercolor="buttonface">
<div align="center"><font color="#000000">密码:</font>
<input type="password" name="pwd" class=textBox1>
</div>
</td>
</tr>
<tr bgcolor="buttonface">
<td colspan="2" bordercolor="buttonface">
<div align="center">
<input onclick="test()" type="submit" name="Submit" value="发送">
<input type="hidden" name="sendid" value="<%=session("bmid")%>">
<input type="hidden" name="recid" value="<%=yid%>">
</div>
</td>
</tr>
</table></form></body>
</html>
<%
else'验证用户PWD
pwd=request("pwd")
user=session("name")
sqlt0="select * from tbluser where name='" & user & "'"
set rs02=conn.execute(sqlt0)
if not rs02.eof then
if pwd<>trim(rs02(2)) then
response.redirect("send-errpwd.htm")
else
idls=request("recid")
sendid=request("sendid")
title=request("title")
mem=request("mem")
mem=replace(mem,chr(10),"<br>")
wtime=formatdatetime(now,0)
'response.write (wtime)
a=split(idls,",")dim str
str=request.form("selstr")response.write (str)
if str<>"" then str=left(str,len(str)-1)
b=split(str,",")for k=0 to ubound(b)
response.write (b(k))
nextfor i=0 to ubound(a)
for k=0 to ubound(b)
randomize time
id=formatdatetime(now,0)
id=replace(id," ","")
id=replace(id,"-","")
id=replace(id,":","")
id="'" & id & int(rnd()*1000) & "'"sqlt="insert into tblmsg values (" & id & ",'" & sendid & "','" & a(i) & "','" & title & "','" & mem & "','" & b(k) & "','" & wtime & "','0')"
conn.execute sqlt next
next
%>
<html>
<head>
<title>消息发送成功</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="sty.css" type="text/css">
</head><body leftmargin="0" topmargin="0" scroll=no>
<table width="157" border="2" cellspacing="0" cellpadding="0" height="258" >
<tr>
<td height="19" width="87%" background="pic/title.gif"><b><font size="2" face="幼圆">发送成功</font></b></td>
<td height="17" width="13%"><img style="CURSOR: hand" src="pic/closeb.gif" width="17" height="17" onClick="window.close()"></td>
</tr>
<tr bordercolor="#000000">
<td height="239" colspan="2">
<div align="center">
<font face="幼圆" size="2"><b>消息发送成功</b></font><br><br>
<a href="qq.asp" ><font face="幼圆" size="1"><b>>>继续发送<<</b></font></a></div>
</td>
</tr>
</table>
</body>
</html><%
'结束密码验证if语句
end if
end if
end if%>
还有想请教response.form()也可以用response.write()来代替吧?
万分感谢!!
没有response.form()的写法
如果说在同一个asp页面中存在多个web页面,将变量从哪个web页面传递到其它web页面都应该是没问题的,不知为什么,在这里就行不通。>:(
。。头大了。。谢了!!
关于response.form(),在你给我例子中的第5行。
改为
<input onclick="test()" type="button" name="Submit" value="发送">
我也是过了,将"submit"改为"button"问题还是解决不了。再次表示感谢
多谢!