50分求助,请看下面的代码,怎么添加不近去啊?很难的!!!!!!!!!!!!!!!!!!!!!
我的意思是这样的。选中select中的任何一条或多条数据,然后单击 "添加 "按纽,然后把数据添加到文本框中去,数据之间用 ", "号隔开,其中数据不能重复,也就是说,假设把aa添近去之后,再添aa,就田不近去了。这个功能我已经实现了。现在的问题是。假设里面有了aabb,这时aa应该能添进去。可是我的不能实现。我的源代码如下:
<script type= "text/javascript " language= "javascript ">
function acceptSubmit()
{
var selectUserName = document.listForm.selectUserName;
var selectText;
with (document.listForm)
{
var sss=toUser.value;
var arr=toUser.value.split( ", ");
for (var i = 0; i < selectUserName.length; i++)
{
if (selectUserName.options[i].selected)
{
selectText = selectUserName[i].text;
var arr=toUser.value.split( ", ");
if (toUser.value.indexOf(selectText) == -1)
{
toUser.value += ", " + selectText;
}
}
}
if (toUser.value.indexOf( ', ') == 0)
{
toUser.value =toUser.value.substring(1, toUser.value.length);
}
}
}
</script>
</head>
<body>
<form id= "listForm " name= "listForm " method= "post " action= " ">
<input type=text name= "toUser " value= " " style= "width:2000 ">
<table border= "0 " cellspacing= "0 " cellpadding= "0 ">
<tbody>
<tr>
<td width= "200 " align= "center ">
<select id= "selectUserName " name= 'selectUserName " ' multiple size= "10 "style= "width: 200px;height:260px ">
&