日期:2014-05-16  浏览次数:20396 次

怎么实现选择控件和textbox控件显示内容的互动?
多项选择
然后textbox控件里面的内容是根据多项选择里面的选择项动态生成的?
这样的功能   怎么用   javascript脚本来实现啊?


------解决方案--------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN ">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME= "Generator " CONTENT= "EditPlus ">
<META NAME= "Author " CONTENT= " ">
<META NAME= "Keywords " CONTENT= " ">
<META NAME= "Description " CONTENT= " ">
</HEAD>

<BODY>
<select onchange= "dd(this) ">
<option value= "1 "> 11 </option>
<option value= "2 "> 22 </option>
</select >
<input type= "text " name= "aa " id= "aa ">
<script>
function dd(a){
if(a.value== "1 "){
document.getElementById( "aa ").value= "11 "
}
if(a.value== "2 "){
document.getElementById( "aa ").value= "22 "
}
}
</script>
</BODY>
</HTML>
------解决方案--------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd ">
<html xmlns= "http://www.w3.org/1999/xhtml ">
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 " />
<title> test </title>
<script type= "text/javascript ">
function itemCheck()
{
var ochkForm = document.getElementById( 'resForm ');
var oText = document.getElementById( 'content ');
var ochkBoxes = ochkForm[ 'items[] '];
oText.value = ' ';
for(var i = 0 ; i <ochkBoxes.length; i++ )
{
if ( ochkBoxes[i].checked )
oText.value += ochkBoxes[i].value+ ' ';
}
}
</script>
</head>
<body>
<form id= "resForm " name= "resForm " >
<textarea id= "content " name= "content "> </textarea>
<br>
<input type= "checkbox " name= "items[] " value= "1 " onclick= "itemCheck() "> 选项1 <br/>
<input type= "checkbox " name= "items[] " value= "2 " onclick= "itemCheck() "> 选项2 <br/>
<input type= "checkbox " name= "items[] " value= "3 " onclick= "itemCheck() "> 选项3 <br/>
<input type= "checkbox " name= "items[] " value= "4 " onclick= "itemCheck() "> 选项4 <br/>
</form>
</body>

</html>

------解决方案--------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN ">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME= "Generator " CONTENT= "EditPlus ">
<META NAME= "Author " CONTENT= " ">
<META NAME= "Keywords " CONTENT= " ">
<META NAME= "Description " CONTENT= " ">
</HEAD>

<BODY>
<select onchange= "dd(this) ">
<option v