JavaScript 在网页中使用的问题? 在线等! :)
我用JavaScript 写了一个把一个列表框A的值添加到另一个列表框B可以实现!我现在想把B中的某一条清除,怎么做啊! 请大家帮忙!!!
添加的代码是:
function AddUser_Click()
{
for (var i=0 ; i <=form2.FriendList.options.length -1 ; i++)
{
{
if (form2.FriendList .options [i].selected )
{
var element = window.Option.create(form2.FriendList.options [i].text, form2.FriendList.options[i].value,0);
form2.ChatList.add(element);
}
}
}
} 删除怎么做啊! 多谢帮助!
------解决方案--------------------L@_@K
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns= "http://www.w3.org/1999/xhtml ">
<head>
<title> new document </title>
<meta name= "generator " content= "editplus " />
<meta name= "author " content= "yixianggao@126.com " />
<meta name= "keywords " content= "javascript " />
<meta name= "description " content= "for javascript region of csdn " />
</head>
<body>
<form name= "form2 ">
<select name= "FriendList " size= "3 ">
<option value= "1 "> calico </option>
<option value= "2 "> tortie </option>
<option value= "3 "> siamese </option>
</select>
<input type= "button " id= "btnAdd " value= "Add > > " onclick= "AddUser_Click() " />
<select name= "ChatList " size= "3 ">
</select>
</form>
<script type= "text/javascript ">
<!--
function AddUser_Click()
{
for (var i=0 ; i <=form2.FriendList.options.length -1 ; i++)
{
if (form2.FriendList.options[i].selected )
{
form2.ChatList.options.add(new Option(form2.FriendList.options[i].text, form2.FriendList.options[i].value));
form2.FriendList.options.remove(i);
}
}
}
//-->
</script>
</body>
</html>