RemoveME function removes more than one item when populating the select fields from the user input feilds instead of the select fields.
[code]
<HEAD>
<SCRIPT LANGUAGE=”JavaScript”>
<!– Begin
function moveOver()
{
var boxLength = document.choiceForm.choiceBox.length;
var selectedItem = document.choiceForm.available.selectedIndex;
var selectedText = document.choiceForm.available.options[selectedItem].text;
var selectedValue = document.choiceForm.available.options[selectedItem].value;
var i;
var isNew = true;
if (boxLength != 0) {
for (i = 0; i < boxLength; i++) {
thisitem = document.choiceForm.choiceBox.options[i].text;
if (thisitem == selectedText) {
isNew = false;
break;
}
}
}
if (isNew) {
newoption = new Option(selectedText, selectedValue, false, false);
document.choiceForm.choiceBox.options[boxLength] = newoption;
}
document.choiceForm.available.selectedIndex=-1;
}
function removeMe() {
var boxLength = document.choiceForm.choiceBox.length;
arrSelected = new Array();
var count = 0;
for (i = 0; i < boxLength; i++) {
if (document.choiceForm.choiceBox.options[i].selected) {
arrSelected[count] = document.choiceForm.choiceBox.options[i].value;
}
count++;
}
var x;
for (i = 0; i < boxLength; i++) {
for (x = 0; x < arrSelected.length; x++) {
if (document.choiceForm.choiceBox.options[i].value == arrSelected[x]) {
document.choiceForm.choiceBox.options[i] = null;
}
}
boxLength = document.choiceForm.choiceBox.length;
}
}
function reshow() {
whatTo = document.choiceForm.elements.choiceBox;
for (var i = whatTo.length;i > 0;i–)
whatTo.options[0] = null;
if (document.choiceForm.manual4.value != ”) {
showLink();
}
else {}
}
function showLink() {
opt(document.choiceForm.manual0.value);
opt(document.choiceForm.manual1.value);
opt(document.choiceForm.manual2.value);
opt(document.choiceForm.manual3.value);
}
function opt(text) {
var optionName = new Option(text)
var length = whatTo.length;
whatTo.options[length] = optionName;
}
// End –>
</script>
</HEAD>
<BODY>
<center>
<form name=”choiceForm”>
<table border=0>
<tr>
<td valign=”top” width=175>
Available Content:
<br>
<select name=”available” size=10 onchange=”moveOver();”>
<option value=1>Company News
<option value=2>Industry News
<option value=3>Product Updates
</select>
</td>
<td valign=”top”>
Your Choices:
<br>
<select name=”choiceBox” style=”width:150;” size=”10″ onchange=”removeMe();”>
</select>
</td>
</tr>
<tr>
<td colspan=2 height=10>
</td>
</tr>
</table>
<input type=”button” value=”Get Selected Values” onclick=”reshow();”>
<input type=”text” value=”Company News” name=”manual0″>
<input type=”text” value=”Industry News” name=”manual1″>
<input type=”text” value=”Product Updates” name=”manual2″>
<input type=”text” value=”Help Me” name=”manual3″>
<input type=”hidden” value=w34 name=”manual4″>
</form>
</center>