用JS 将多个checkbox 里面的值提取出来,在依次显示在TEXT的文本框中,如何实现?文本框显示多个值噢
<formname="form1"onSubmit=""><textareatype="textarea"name="m1"cols="45"rows="5"/></te...
<form name="form1" onSubmit="">
<textarea type="textarea" name="m1"cols="45" rows="5" /></textarea>
</form>
<form action="" method="post" name="form2" onSubmit="return chk();">
审核人:<input type="textarea" name="name"/><br/>
张三<input type="checkbox" name="m1" value="张三" onClick="fun(this.form)" />
<br/>
李四<input type="checkbox" name="m1" value="李四" onClick="fun(this.form)"/><br/>
<input type="button" name="b1" value="view" onClick="selected(this.form)" />
</form>
<script language="javascript">
function selected(bb){
var temp="";
for(var i=0;i<bb.r1.length;i++)
{
if(bb.r1[i].checked)
//alert(bb.r1[i].value);
temp+=bb.r1[i].value+"<br>";
}
if(temp!="")document.write(temp);
}
</script>
<script>
var temp="";
function fun(num){
for(var i=0;i<num.m1.length;i++)
{
if(num.m1[i].checked)
//alert(bb.r1[i].value);
temp+=num.m1[i].value+"<br>";
}
var f2 = document.form2.name;
var f1 = document.form1;
if(temp!="")f1.m1.value = temp;//document.write(temp);
var name = document.form2.name;
var r = document.form2.m1;
for(var i=0; i<r.length; i++){
if(r[i].checked){
name.value = r[i].value;
f1.m1.value = f2.value;
}
}
}
//-->
</script>
自己瞎写的一段代码, 只能在TEXT中输入一个值, 请高手指点 展开
<textarea type="textarea" name="m1"cols="45" rows="5" /></textarea>
</form>
<form action="" method="post" name="form2" onSubmit="return chk();">
审核人:<input type="textarea" name="name"/><br/>
张三<input type="checkbox" name="m1" value="张三" onClick="fun(this.form)" />
<br/>
李四<input type="checkbox" name="m1" value="李四" onClick="fun(this.form)"/><br/>
<input type="button" name="b1" value="view" onClick="selected(this.form)" />
</form>
<script language="javascript">
function selected(bb){
var temp="";
for(var i=0;i<bb.r1.length;i++)
{
if(bb.r1[i].checked)
//alert(bb.r1[i].value);
temp+=bb.r1[i].value+"<br>";
}
if(temp!="")document.write(temp);
}
</script>
<script>
var temp="";
function fun(num){
for(var i=0;i<num.m1.length;i++)
{
if(num.m1[i].checked)
//alert(bb.r1[i].value);
temp+=num.m1[i].value+"<br>";
}
var f2 = document.form2.name;
var f1 = document.form1;
if(temp!="")f1.m1.value = temp;//document.write(temp);
var name = document.form2.name;
var r = document.form2.m1;
for(var i=0; i<r.length; i++){
if(r[i].checked){
name.value = r[i].value;
f1.m1.value = f2.value;
}
}
}
//-->
</script>
自己瞎写的一段代码, 只能在TEXT中输入一个值, 请高手指点 展开
2个回答
展开全部
<form name="form1" onSubmit="">
<textarea type="textarea" name="t1"cols="45" rows="5" /></textarea>
</form>
<form action="" method="post" name="form2" onSubmit="return chk();">
审核人:<input type="textarea" name="name"/><br/>
张三<input type="checkbox" name="m1" value="张三" onClick="fun(this.form)" />
<br/>
李四<input type="checkbox" name="m1" value="李四" onClick="fun(this.form)"/><br/>
<input type="button" name="b1" value="view" onClick="selected(this.form)" />
</form>
<script language="javascript">
function selected(bb){
var temp="";
for(var i=0;i<bb.m1.length;i++)
{
if(bb.m1[i].checked)
//alert(bb.r1[i].value);
temp+=bb.m1[i].value+"<br>";
}
if(temp!="")document.write(temp);
}
</script>
<script>
function fun(num){
temp="";
for(var i=0;i<num.m1.length;i++){
if(num.m1[i].checked){
temp+=num.m1[i].value+" ";
}
}
var f2 = document.form2.name;
var f1 = document.form1;
f1.t1.value = temp;//document.write(temp);
var name = document.form2.name;
var r = document.form2.m1;
name.value = '';
for(var i=0; i<r.length; i++){
if(r[i].checked){
name.value = r[i].value;
f1.m1.value = f2.value;
}
}
}
//-->
</script>
<textarea type="textarea" name="t1"cols="45" rows="5" /></textarea>
</form>
<form action="" method="post" name="form2" onSubmit="return chk();">
审核人:<input type="textarea" name="name"/><br/>
张三<input type="checkbox" name="m1" value="张三" onClick="fun(this.form)" />
<br/>
李四<input type="checkbox" name="m1" value="李四" onClick="fun(this.form)"/><br/>
<input type="button" name="b1" value="view" onClick="selected(this.form)" />
</form>
<script language="javascript">
function selected(bb){
var temp="";
for(var i=0;i<bb.m1.length;i++)
{
if(bb.m1[i].checked)
//alert(bb.r1[i].value);
temp+=bb.m1[i].value+"<br>";
}
if(temp!="")document.write(temp);
}
</script>
<script>
function fun(num){
temp="";
for(var i=0;i<num.m1.length;i++){
if(num.m1[i].checked){
temp+=num.m1[i].value+" ";
}
}
var f2 = document.form2.name;
var f1 = document.form1;
f1.t1.value = temp;//document.write(temp);
var name = document.form2.name;
var r = document.form2.m1;
name.value = '';
for(var i=0; i<r.length; i++){
if(r[i].checked){
name.value = r[i].value;
f1.m1.value = f2.value;
}
}
}
//-->
</script>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询