怎么点击获取已选择的值
1.asp:
<script language="javascript">
function inputs()
{
window.open("2.asp","","");
}
</script>
<textarea name="jsr" id="jsr" cols="60" onclick="javascript:inputs();"></textarea>
2.asp:
<%set rsm=server.CreateObject("adodb.recordset")
rsm.open "select * from xueyuan where (mx='"&session("mx")&"' or mx='"&session("name")&"') order by xm ASC",conn,1,3%>
<form name="form" method="post" action="">
全选:<input type="checkbox" name="checkbox2" value="checkbox" onClick="CheckAll(this.form)" />
<%do while not rsm.eof%>
<input name="dh" type="checkbox" id="dh" value="<%=rsm("dh1")%>"><%=rsm("xm")%><%
rsm.movenext
loop
%>
<input name="an" type="button" onClick="" value="确定" /></form>
请问如何写才能达到以下功能:
点击红色代码的“确定”按纽后将蓝色的name="checkbox2"值返回到1.asp中的name="jsr"里,当然,选择了多个蓝色的name="checkbox2"复选框,则返回到1.asp中的name="jsr"里的值自动用逗号隔开
------解决方案-------------------- <input name="an" type="button" onclick="onClick()" value="确定" /></form>
<script language="javascript">
function onClick()
{
var checkboxs = new Array();
var objs = document.getElementsByName("dh");
for (var i=0; i<objs.length; i++){
if(objs[i].checked) {
checkboxs.push(objs[i].value);
}
}
window.opener.jsr.innerHTML = checkboxs.toString();
}
</script>
------解决方案--------------------<input name="an" type="button" onClick="setOpener()" value="确定" />
<script>
function setOpener() {
var f = document.form, v = '';
if (f.dh.length) {
for (var i = 0, j = f.dh.length; i < j; i++)
if (f.dh[i].checked) v += ',' + f.dh[i].value;
if (v != '') v = v.substring(1);
}
else if (f.dh.checked) v = f.dh.value;
if (v != '') opener.document.getElementById('jsr').value = v;
}
</script>