首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

html,jsp的简单有关问题,100分在线求教,请达人帮忙!

2012-02-26 
html,jsp的简单问题,100分在线求教,请达人帮忙!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!最后的分数了,在线等

html,jsp的简单问题,100分在线求教,请达人帮忙!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
最后的分数了,在线等答复,立刻给分.
请问如何用html或jsp可以做到在点击列表框和按钮时,使列表框中选择的内容和按钮的名字出现在textarea中.(我感觉只能用JSP实现,不知道对不对)
html代码如下,请高手帮写几句代码.谢谢先

<html>
<head>
<title> aa </title>
</head>
<body>

<form   action= "list.jsp "   method= "POST "> Field
<br>
<select   name= "field "   multiple>  
<option   value= "hk "> Hong   Kong </option>  
<option   value= "tw "   > Taiwan </option>  
<option   value= "cn "> China </option>  
<option   value= "us "> United   States </option>  
<option   value= "ca "> Canada </option>  
</select>  

<br>
<input   type= "Button "   value= "> ">  
<input   type= "Button "   value= "&lt; ">  
<input   type= "Button "   value= "> = ">
<input   type= "Button "   value= "&lt;= ">  
<input   type= "Button "   value= "= ">
<input   type= "Button "   value= "_ "   >  

<br>
<input   type= "Button "   value= "and ">
<input   type= "Button "   value= "or ">
<input   type= "Button "   value= "not ">
<input   type= "Button "   value= "is ">
<input   type= "Button "   value= "% ">


<br> SQL
<textarea   name= "comments "   cols= "40 "   rows= "4 ">  
</textarea>  

<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input   type= "Submit "   value= "应用 ">
<input   type= "Reset "   value= "置空 ">

</form>  

</body>
</html>

[解决办法]
<html>
<head>
<script language= "javascript ">
function getname(initValue){
var s= " ";
if(document.form1.comments.value != " "){
s = document.form1.comments.value;
}
s += initValue + " ";
document.form1.comments.value = s;
}
function clearvlue(){
document.form1.comments.value = " ";
}
</script>
<title> aa </title>
</head>
<body>

<form name= "form1 " action= "list.jsp " method= "POST "> Field
<br>
<select name= "field " multiple onchange= "getname(this.value); ">
<option value= "hk "> Hong Kong </option>
<option value= "tw " > Taiwan </option>
<option value= "cn "> China </option>
<option value= "us "> United States </option>
<option value= "ca "> Canada </option>
</select>

<br>
<input type= "Button " value= "> " onclick= "getname(this.value); ">


<input type= "Button " value= "&lt; " onclick= "getname(this.value); ">
<input type= "Button " value= "> = " onclick= "getname(this.value); ">
<input type= "Button " value= "&lt;= " onclick= "getname(this.value); ">
<input type= "Button " value= "= " onclick= "getname(this.value); ">
<input type= "Button " value= "_ " onclick= "getname(this.value); ">

<br>
<input type= "Button " value= "and " onclick= "getname(this.value); ">
<input type= "Button " value= "or " onclick= "getname(this.value); ">
<input type= "Button " value= "not " onclick= "getname(this.value); ">
<input type= "Button " value= "is " onclick= "getname(this.value); ">
<input type= "Button " value= "% " onclick= "getname(this.value); ">


<br> SQL
<textarea name= "comments " cols= "40 " rows= "4 ">
</textarea>

<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type= "Submit " value= "应用 ">
<input type= "button " value= "置空 " onclick= "clearvlue() ">

</form>

</body>
</html>

[解决办法]
<html>
<head>
<title> aa </title>
</head>
<body>

<form action= "list.jsp " method= "POST "> Field
<br>
<select name= "field " multiple onChange= "document.all.comments.innerHTML+=this.options[this.selectedIndex].innerHTML; ">
<option value= "hk "> Hong Kong </option>
<option value= "tw " > Taiwan </option>
<option value= "cn "> China </option>
<option value= "us "> United States </option>
<option value= "ca "> Canada </option>
</select>

<br>
<input type= "Button " value= "> " onClick= "document.all.comments.innerHTML+=this.value; ">
<input type= "Button " value= "&lt; ">
<input type= "Button " value= "> = ">
<input type= "Button " value= "&lt;= ">
<input type= "Button " value= "= ">
<input type= "Button " value= "_ " >

<br>
<input type= "Button " value= "and ">
<input type= "Button " value= "or ">
<input type= "Button " value= "not ">
<input type= "Button " value= "is ">
<input type= "Button " value= "% ">


<br> SQL
<textarea name= "comments " cols= "40 " rows= "4 ">
</textarea>

<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type= "Submit " value= "应用 ">
<input type= "Reset " value= "置空 ">

</form>



</body>
</html>


---------------------------------------------------
列表框 和 第一个 按钮帮你写好了
其他按钮 copy 第一个 就 ok了
[解决办法]
没事做帮你写了一个
<script language= "javascript ">
function add(){
var select = document.getElementById( "select ");

for(var i = 0; i < select.options.length; i++){
if (select.options[i].selected){
document.getElementById( "textarea ").value += select.options[i].text + "\r\n ";
}
}



}
</script>

<br>
<select name= "field " id= "select " multiple width=30%>
<option value= "hk "> Hong Kong </option>
<option value= "tw " > Taiwan </option>
<option value= "cn "> China </option>
<option value= "us "> United States </option>
<option value= "ca "> Canada </option>
</select>

<br>
<input type= "Button " value= "> " onclick= "add() ">
<input type= "Button " value= "&lt; ">
<input type= "Button " value= "> = ">
<input type= "Button " value= "&lt;= ">
<input type= "Button " value= "= ">
<input type= "Button " value= "_ " >

<br>
<input type= "Button " value= "and ">
<input type= "Button " value= "or ">
<input type= "Button " value= "not ">
<input type= "Button " value= "is ">
<input type= "Button " value= "% ">


<br> SQL
<textarea id= "textarea " name= "comments " cols= "40 " rows= "4 ">
</textarea>

<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type= "Submit " value= "应用 ">
<input type= "Reset " value= "置空 ">

热点排行