<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<script>
function fun(){var ary = document.getElementsByName("a");
var str = "";
for(var i=0;i<ary.length;i++){ if(ary[i].checked){
str = str + ary[i].value;
} }
document.getElementById("text").value = str;
}
</script>
</HEAD> <BODY>
<form>
<table>
<tr>
<td>
<input type="checkbox" name="a" value="aaa" onclick = "fun()">
<input type="checkbox" name="a" value="bbb" onclick = "fun()">
<input type="checkbox" name="a" value="ccc" onclick = "fun()">
<td>
<textarea name="text" cols="60" rows="10" readonly></textarea>
</td>
</tr>
</table>
</form>
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<script>
function fun(){var ary = document.getElementsByName("a");
var str = "";
for(var i=0;i<ary.length;i++){ if(ary[i].checked){
str = str + ary[i].value;
} }
document.getElementById("text").value = str;
}
</script>
</HEAD> <BODY>
<form>
<table>
<tr>
<td>
<input type="checkbox" name="a" value="aaa" onclick = "fun()">
<input type="checkbox" name="a" value="bbb" onclick = "fun()">
<input type="checkbox" name="a" value="ccc" onclick = "fun()">
<td>
<textarea name="text" cols="60" rows="10" readonly></textarea>
</td>
</tr>
</table>
</form>
function show(obj){
if(obj.checked == true){
document.getElementsByName('text')[0].value +=obj.value;
}else{
var re = new RegExp("["+obj.value+"]","g");
document.getElementsByName('text')[0].value = document.getElementsByName('text')[0].value.replace(re,"");
}
}
</script>
<table>
<tr>
<td>
<input type="checkbox" name="a" value="a" onclick="show(this);">
<input type="checkbox" name="b" value="b" onclick="show(this);">
<input type="checkbox" name="c" value="c" onclick="show(this);">
<td>
<textarea name="text" cols="60" rows="10" readonly></textarea>
</td>
</tr>
</table>
参考一下吧
<HTML >
<HEAD >
<SCRIPT LANGUAGE="JavaScript">
<!--
function fun1()
{
if (window.document.all.a.value=="1")
{
window.document.all.a.value="0";
window.document.all.text1.value=window.document.all.text1.value+window.document.all.a1.value;
}
else if (window.document.all.a.value=="0")
{
window.document.all.a.value="1";
window.document.all.text1.value = window.document.all.text1.value.replace(window.document.all.a1.value,"");
}
}
function fun2()
{
if (window.document.all.b.value=="1")
{
window.document.all.b.value="0";
window.document.all.text1.value=window.document.all.text1.value+window.document.all.b1.value;
}
else if (window.document.all.b.value=="0")
{
window.document.all.b.value="1";
window.document.all.text1.value = window.document.all.text1.value.replace(window.document.all.b1.value,"");
}
}
function fun3()
{
if (window.document.all.c.value=="1")
{
window.document.all.c.value="0";
window.document.all.text1.value=window.document.all.text1.value+window.document.all.c1.value;
}
else if (window.document.all.c.value=="0")
{
window.document.all.c.value="1";
window.document.all.text1.value = window.document.all.text1.value.replace(window.document.all.c1.value,"");
}
}
//-->
</SCRIPT>
<TITLE > New Document </TITLE > </HEAD > <BODY >
<form name="form">
<table >
</tr>
<td >
<textarea name="text1" cols="60" rows="10" readonly > </textarea >
</td >
</tr >
<tr >
<td >
苹果<input type="checkbox" name="a" value="1" onclick = "fun1()"/ >
<input type="hidden" name="a1" value="苹果"/ >
梨子<input type="checkbox" name="b" value="1" onclick = "fun2()" />
<input type="hidden" name="b1" value="梨子"/ >
香蕉<input type="checkbox" name="c" value="1" onclick = "fun3()"/ >
<input type="hidden" name="c1" value="香蕉"/ >
</td>
</tr>
</table >
</form >
</body>
</html>