|
<% @LANGUAGE=VBSCRIPT%> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>无标题文档</title> </head> <body> <script language="JavaScript"> <!-- /*move(s1,s2,flag):s1是源列表框,s2是目的列表框,flag是是否全部移动*/ function move(s1,s2,flag){ var tem=new Array(); var sa=document.frm.elements[s1]; var sb=document.frm.elements[s2]; var s=sa.selectedIndex>-1?1:0 with(sa) for(i=length-1;i>=0;i--) if(options[i].selected||flag){tem[tem.length]=options[i];options[i]=null} if(s||flag){ for(i=0;i<sb.length;i++)tem[tem.length]=sb.options[i] with(sb){ length=0; tem.sort(sortArr) for(i=0;i<tem.length;i++)options[length]=new Option(tem[i].text,tem[i].value) } } } /*move_self(s,flag):s是列表框name,flag(1,-1),是上移或下移*/ function move_self(s,flag){ var sa=document.frm.elements[s] var tem; with(sa){ if(flag==1){ if(selectedIndex>0) for(i=0;i<length;i++) if(options[i].selected){ tem_text=options[i].text;tem_value=options[i].value options[i].text=options[i-1].text; options[i].value=options[i-1].value; options[i-1].text=tem_text;options[i-1].value=tem_value options[i-1].selected=true;options[i].selected=false } } else for(i=length-1;i>=0;i--) if(options[i].selected){ if(i==length-1)break; tem_text=options[i].text;tem_value=options[i].value options[i].text=options[i+1].text; options[i].value=options[i+1].value; options[i+1].text=tem_text;options[i+1].value=tem_value options[i+1].selected=true;options[i].selected=false } } } /*显示列表框选中的值,s是列表框的name*/ function show(s){ var str="" with(document.frm.elements[s]) for(i=0;i<length;i++) if(options[i].selected)str+="\n第"+(i+1)+"个option:\ntext:"+options[i].text+" value:"+options[i].value alert(str) } function sortArr(a,b){ if(a.text>b.text)return 1 if(a.text<b.text)return -1 return 0 } //--> </script> <%dim dz(50) Dno=request("Dno") set cnn=server.CreateObject("adodb.connection") cnnstr="DRIVER={SQL SERVER};SERVER=22.141.1.37;UID=infos;PWD=infos;DATABASE=stinfos" cnn.open cnnstr set rs=server.CreateObject("adodb.recordset") sqlstr="select dep from id_table" rs.open sqlstr,cnn,1,1 %> <form name="frm" action="../upfile/savereader.asp"> <table width="750" border="1" align="center" cellspacing="2" bordercolor="#FF0000"> <tr align="center" valign="middle"> <td colspan="3">为<%=Dno%>号文添加读者</td> </tr> <tr> <td align="right"> <select name="a" size="5" style="width:150" multiple> <% i=1 do while not rs.eof response.Write("<option value="&rs("dep")&">"&rs("dep")&"</option>") dz(i)=rs("dep") i=i+1 rs.movenext loop rs.close set rs=nothing cnn.close set cnn=nothing %> </select> </td> <td width="77" align="left" valign="middle"> <input name="button3" type=button onclick="move('a','b')" value="添加>"> <br> <input name="button" type=button onclick="move('a','b',1)" value="添加全部"> <br> <input name="button5" type=button onclick="move('b','a')" value="<删除"> <br> <input name="button2" type=button onclick="move('b','a',1)" value="删除全部"> </td> <td width="337"><select name="b" size="5" style="width:150" multiple> </select></td> </tr> <tr> <td height="47" align="right"> </td> <td> </td> <td> </td> </tr> </table> <br> <br> </form> </body> </html> |
|
|
|
拜托各位了啊!!!!!!!救命救命!~~~~
|
|
|
你的代码还没制定submit的method
|
|
|
即使能在在b框中显示出数据
为何 查看运行后的代码发现b框的options中是没有数据 不明白? |
|
|
xiaobird1大哥!请问您说的是什么意思!?小弟是新学asp啊!要指定submit的method是应该怎么指定?!在哪里?!button那吗?
|
|
|
关注!
|
|
|
lihua9666大哥!这就是困扰小弟的问题啊!会不会是js函数的问题呢?!但是我看不懂那段js函数的代码,其实这是我拷人家的程序后改的!拜托各位!谢谢!
|
|
|
<form name="frm" action="../upfile/savereader.asp" method="post">
|
|
|
<% @LANGUAGE=VBSCRIPT%>
<% ' -- Save to MyDB if Request.QueryString("action") = "new" then Response.write Request.Form("b") end if %> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>无标题文档</title> </head> <body> <script language="JavaScript"> <!-- /*move(s1,s2,flag):s1是源列表框,s2是目的列表框,flag是是否全部移动*/ function move(s1,s2,flag){ var tem=new Array(); var sa=document.frm.elements[s1]; var sb=document.frm.elements[s2]; var s=sa.selectedIndex>-1?1:0 with(sa) for(i=length-1;i>=0;i--) if(options[i].selected||flag){tem[tem.length]=options[i];options[i]=null} if(s||flag){ for(i=0;i<sb.length;i++)tem[tem.length]=sb.options[i] with(sb){ length=0; tem.sort(sortArr) for(i=0;i<tem.length;i++)options[length]=new Option(tem[i].text,tem[i].value) } } } /*move_self(s,flag):s是列表框name,flag(1,-1),是上移或下移*/ function move_self(s,flag){ var sa=document.frm.elements[s] var tem; with(sa){ if(flag==1){ if(selectedIndex>0) for(i=0;i<length;i++) if(options[i].selected){ tem_text=options[i].text;tem_value=options[i].value options[i].text=options[i-1].text; options[i].value=options[i-1].value; options[i-1].text=tem_text;options[i-1].value=tem_value options[i-1].selected=true;options[i].selected=false } } else for(i=length-1;i>=0;i--) if(options[i].selected){ if(i==length-1)break; tem_text=options[i].text;tem_value=options[i].value options[i].text=options[i+1].text; options[i].value=options[i+1].value; options[i+1].text=tem_text;options[i+1].value=tem_value options[i+1].selected=true;options[i].selected=false } } } /*显示列表框选中的值,s是列表框的name*/ function show(s){ var str="" with(document.frm.elements[s]) for(i=0;i<length;i++) if(options[i].selected)str+="\n第"+(i+1)+"个option:\ntext:"+options[i].text+" value:"+options[i].value alert(str) } function sortArr(a,b){ if(a.text>b.text)return 1 if(a.text<b.text)return -1 return 0 } //--> </script> <%dim dz(50) Dno=request("Dno") 'set cnn=server.CreateObject("adodb.connection") 'cnnstr="DRIVER={SQL SERVER};SERVER=(local);UID=toeic;PWD=toeic123;DATABASE=stinfos" 'cnn.open cnnstr 'set rs=server.CreateObject("adodb.recordset") 'sqlstr="select dep from id_table" 'rs.open sqlstr,cnn,1,1 %> <form name="frm" method="Post" action="1.asp?action=new" > <table width="750" border="1" align="center" cellspacing="2" bordercolor="#FF0000"> <tr align="center" valign="middle"> <td colspan="3">为<%=Dno%>号文添加读者</td> </tr> <tr> <td align="right"> <select name="a" size="5" style="width:150"> <%' -- Add some value here %> <option value=1>1</option> <option value=2>2</option> <option value=3>3</option> <option value=4>4</option> </select> </td> <td width="77" align="left" valign="middle"> <input name="button3" type=button onclick="move('a','b')" value="添加>"> <br> <input name="button" type=button onclick="move('a','b',1)" value="添加全部"> <br> <input name="button5" type=button onclick="move('b','a')" value="<删除"> <br> <input name="button2" type=button onclick="move('b','a',1)" value="删除全部"> </td> <td width="337"><select name="b" size="5" multiple id="b" style="width:150"> </select></td> </tr> <tr> <td height="47" align="right"> </td> <td> </td> <td> </td> </tr> </table> <br> <br> <input type=submit onclick="clk()"> </form> </body> <SCRIPT LANGUAGE="JavaScript"> <!-- function clk() { alert( frm.b.value); } //--> </SCRIPT> </html> |
|
|
帮你改了改。
现在可以提交和接受数据了。 不过我把action设为了本页,作了注释。你自己改回来吧。 |
|
|
xiaobird1大哥!加了那个显示b框数据的button弹出来的窗口出来是空的!我就是不理解为什么!
|
|
|
xiaobird1大哥!还是不行!~没有数据显示,按你上面的代码,选择之后点击那个按钮还是显示空的!~代码我已经改成和你给的一样的了!~
|
|
|
那个提示框吗?
要选择数据在提交呀! 还是什么??? |
|
|
还不行,QQ加我
120101412 |
|
|
<% @LANGUAGE=VBSCRIPT%>
<% set cnn=server.CreateObject("adodb.connection") set rs=server.CreateObject("adodb.recordset") cnnstr="DRIVER={SQL SERVER};SERVER=(local);UID=toeic;PWD=toeic123;DATABASE=stinfos" cnn.open cnnstr ' -- Save to MyDB dim szDep if Request.QueryString("action") = "new" then szDep = Split(Request.Form("b"),",") For i = 0 To Ubound(szDep) sql = "Insert Into id_table(dep) Values('" & szDep(i) & "')" Response.write sql cnn.execute(sql) next end if %> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>无标题文档</title> </head> <body> <script language="JavaScript"> <!-- /*move(s1,s2,flag):s1是源列表框,s2是目的列表框,flag是是否全部移动*/ function move(s1,s2,flag){ var tem=new Array(); var sa=document.frm.elements[s1]; var sb=document.frm.elements[s2]; var s=sa.selectedIndex>-1?1:0 with(sa) for(i=length-1;i>=0;i--) if(options[i].selected||flag){tem[tem.length]=options[i];options[i]=null} if(s||flag){ for(i=0;i<sb.length;i++)tem[tem.length]=sb.options[i] with(sb){ length=0; tem.sort(sortArr) for(i=0;i<tem.length;i++)options[length]=new Option(tem[i].text,tem[i].value) } } } /*move_self(s,flag):s是列表框name,flag(1,-1),是上移或下移*/ function move_self(s,flag){ var sa=document.frm.elements[s] var tem; with(sa){ if(flag==1){ if(selectedIndex>0) for(i=0;i<length;i++) if(options[i].selected){ tem_text=options[i].text;tem_value=options[i].value options[i].text=options[i-1].text; options[i].value=options[i-1].value; options[i-1].text=tem_text;options[i-1].value=tem_value options[i-1].selected=true;options[i].selected=false } } else for(i=length-1;i>=0;i--) if(options[i].selected){ if(i==length-1)break; tem_text=options[i].text;tem_value=options[i].value options[i].text=options[i+1].text; options[i].value=options[i+1].value; options[i+1].text=tem_text;options[i+1].value=tem_value options[i+1].selected=true;options[i].selected=false } } } /*显示列表框选中的值,s是列表框的name*/ function show(s){ var str="" with(document.frm.elements[s]) for(i=0;i<length;i++) if(options[i].selected)str+="\n第"+(i+1)+"个option:\ntext:"+options[i].text+" value:"+options[i].value alert(str) } function sortArr(a,b){ if(a.text>b.text)return 1 if(a.text<b.text)return -1 return 0 } //--> </script> <%dim dz(50) Dno=request("Dno") sqlstr="select dep from id_table" rs.open sqlstr,cnn,1,1 %> <form name="frm" method="Post" action="1.asp?action=new" > <table width="750" border="1" align="center" cellspacing="2" bordercolor="#FF0000"> <tr align="center" valign="middle"> <td colspan="3">为<%=Dno%>号文添加读者</td> </tr> <tr> <td align="right"> <select name="a" size="5" style="width:150"> <%' -- Add some value here %> <option value=1>1</option> <option value=2>2</option> <option value=3>3</option> <option value=4>4</option> </select> </td> <td width="77" align="left" valign="middle"> <input name="button3" type=button onclick="move('a','b')" value="添加>"> <br> <input name="button" type=button onclick="move('a','b',1)" value="添加全部"> <br> <input name="button5" type=button onclick="move('b','a')" value="<删除"> <br> <input name="button2" type=button onclick="move('b','a',1)" value="删除全部"> </td> <td width="337"><select name="b" size="5" multiple id="b" style="width:150"> </select></td> </tr> <tr> <td height="47" align="right"> </td> <td> </td> <td> </td> </tr> </table> <br> <br> <input type=submit onclick="clk()"> </form> </body> <SCRIPT LANGUAGE="JavaScript"> <!-- function clk() { alert( frm.b.value); } //--> </SCRIPT> </html> |
|
|
<% @LANGUAGE=VBSCRIPT%>
<% set cnn=server.CreateObject("adodb.connection") set rs=server.CreateObject("adodb.recordset") cnnstr="DRIVER={SQL SERVER};SERVER=(local);UID=toeic;PWD=toeic123;DATABASE=stinfos" cnn.open cnnstr ' -- Save to MyDB dim szDep if Request.QueryString("action") = "new" then szDep = Split(Request.Form("b"),",") For i = 0 To Ubound(szDep) sql = "Insert Into id_table(dep) Values('" & szDep(i) & "')" Response.write sql cnn.execute(sql) next end if %> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>无标题文档</title> </head> <body> <script language="JavaScript"> <!-- /*move(s1,s2,flag):s1是源列表框,s2是目的列表框,flag是是否全部移动*/ function move(s1,s2,flag){ var tem=new Array(); var sa=document.frm.elements[s1]; var sb=document.frm.elements[s2]; var s=sa.selectedIndex>-1?1:0 with(sa) for(i=length-1;i>=0;i--) if(options[i].selected||flag){tem[tem.length]=options[i];options[i]=null} if(s||flag){ for(i=0;i<sb.length;i++)tem[tem.length]=sb.options[i] with(sb){ length=0; tem.sort(sortArr) for(i=0;i<tem.length;i++)options[length]=new Option(tem[i].text,tem[i].value) } } } /*move_self(s,flag):s是列表框name,flag(1,-1),是上移或下移*/ function move_self(s,flag){ var sa=document.frm.elements[s] var tem; with(sa){ if(flag==1){ if(selectedIndex>0) for(i=0;i<length;i++) if(options[i].selected){ tem_text=options[i].text;tem_value=options[i].value options[i].text=options[i-1].text; options[i].value=options[i-1].value; options[i-1].text=tem_text;options[i-1].value=tem_value options[i-1].selected=true;options[i].selected=false } } else for(i=length-1;i>=0;i--) if(options[i].selected){ if(i==length-1)break; tem_text=options[i].text;tem_value=options[i].value options[i].text=options[i+1].text; options[i].value=options[i+1].value; options[i+1].text=tem_text;options[i+1].value=tem_value options[i+1].selected=true;options[i].selected=false } } } /*显示列表框选中的值,s是列表框的name*/ function show(s){ var str="" with(document.frm.elements[s]) for(i=0;i<length;i++) if(options[i].selected)str+="\n第"+(i+1)+"个option:\ntext:"+options[i].text+" value:"+options[i].value alert(str) } function sortArr(a,b){ if(a.text>b.text)return 1 if(a.text<b.text)return -1 return 0 } //--> </script> <%dim dz(50) Dno=request("Dno") sqlstr="select dep from id_table" rs.open sqlstr,cnn,1,1 %> <form name="frm" method="Post" action="1.asp?action=new" > <table width="750" border="1" align="center" cellspacing="2" bordercolor="#FF0000"> <tr align="center" valign="middle"> <td colspan="3">为<%=Dno%>号文添加读者</td> </tr> <tr> <td align="right"> <select name="a" size="5" style="width:150"> <%' -- Add some value here %> <option value=1>1</option> <option value=2>2</option> <option value=3>3</option> <option value=4>4</option> </select> </td> <td width="77" align="left" valign="middle"> <input name="button3" type=button onclick="move('a','b')" value="添加>"> <br> <input name="button" type=button onclick="move('a','b',1)" value="添加全部"> <br> <input name="button5" type=button onclick="move('b','a')" value="<删除"> <br> <input name="button2" type=button onclick="move('b','a',1)" value="删除全部"> </td> <td width="337"><select name="b" size="5" multiple id="b" style="width:150"> </select></td> </tr> <tr> <td height="47" align="right"> </td> <td> </td> <td> </td> </tr> </table> <br> <br> <input type=submit onclick="clk()"> </form> </body> <SCRIPT LANGUAGE="JavaScript"> <!-- function clk() { for( var i = 0; i < frm.b.options.length; i++ ) frm.b.options[i].selected = true; } //--> </SCRIPT> </html> |
|