Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

List Menu 1

Status
Not open for further replies.

timcadieux

Programmer
May 25, 2005
129
BE
i've got the below code, which works. However, anytime i use the right arrow button to move Text from the left box to the RIGHT, i need the TEXT to be SELECTED. Can someone help me with this?

Code:
<form>
<select multiple size="10" name="Category1" style="width:200">

<option value="Afghanistan">Afghanistan</option>
    <option value="Armour">Armour</option>
    <option value="Artillery">Artillery </option>
    <option value="Awards">Awards  </option>
 </select>
</td>
<td width="10%" align="center" valign="middle">
<input type="button" onClick="move(this.form.Category,this.form.Category1)" value="<<">
<input type="button" onClick="move(this.form.Category1,this.form.Category)" value=">>">
</td>
<td width="45%">
<select multiple size="10" name="Category" style="width:200"></select>

<SCRIPT LANGUAGE="JavaScript">

<!-- Begin
function move(fbox, tbox) {
var arrFbox = new Array();
var arrTbox = new Array();
var arrLookup = new Array();
var i;
for (i = 0; i < tbox.options.length; i++) {
arrLookup[tbox.options[i].text] = tbox.options[i].value;
arrTbox[i] = tbox.options[i].text;
}
var fLength = 0;
var tLength = arrTbox.length;
for(i = 0; i < fbox.options.length; i++) {
arrLookup[fbox.options[i].text] = fbox.options[i].value;
if (fbox.options[i].selected && fbox.options[i].value != "") {
arrTbox[tLength] = fbox.options[i].text;
tLength++;
}
else {
arrFbox[fLength] = fbox.options[i].text;
fLength++;
   }
}
arrFbox.sort();
arrTbox.sort();
fbox.length = 0;
tbox.length = 0;
var c;
for(c = 0; c < arrFbox.length; c++) {
var no = new Option();
no.value = arrLookup[arrFbox[c]];
no.text = arrFbox[c];
fbox[c] = no;
}
for(c = 0; c < arrTbox.length; c++) {
var no = new Option();
no.value = arrLookup[arrTbox[c]];
no.text = arrTbox[c];
tbox[c] = no;
   }
}
//  End -->
</script>
 
try this:
Code:
<select multiple size="10" name="Category1" style="width:200">

<option value="Afghanistan">Afghanistan</option>
    <option value="Armour">Armour</option>
    <option value="Artillery">Artillery </option>
    <option value="Awards">Awards  </option>
 </select>
</td>
<td width="10%" align="center" valign="middle">
<input type="button" onClick="move(this.form.Category,this.form.Category1[highlight],this.form.Category[/highlight])" value="<<">
<input type="button" onClick="move(this.form.Category1,this.form.Category[highlight],this.form.Category[/highlight])" value=">>">
</td>
<td width="45%">
<select multiple size="10" name="Category" style="width:200"></select>

<SCRIPT LANGUAGE="JavaScript">
<!-- begin
function move(fbox, tbox[highlight], boxToSelect[/highlight]) {
	var arrFbox = new Array();
	var arrTbox = new Array();
	var arrLookup = new Array();
	var i;
	for (i = 0; i < tbox.options.length; i++) {
		arrLookup[tbox.options[i].text] = tbox.options[i].value;
		arrTbox[i] = tbox.options[i].text;
	}
	var fLength = 0;
	var tLength = arrTbox.length;
	for(i = 0; i < fbox.options.length; i++) {
		arrLookup[fbox.options[i].text] = fbox.options[i].value;
		if (fbox.options[i].selected && fbox.options[i].value != "") {
			arrTbox[tLength] = fbox.options[i].text;
			tLength++;
		}
		else {
			arrFbox[fLength] = fbox.options[i].text;
			fLength++;
		}
	}
	arrFbox.sort();
	arrTbox.sort();
	fbox.length = 0;
	tbox.length = 0;
	var c;
	for(c = 0; c < arrFbox.length; c++) {
		var no = new Option();
		no.value = arrLookup[arrFbox[c]];
		no.text = arrFbox[c];
		fbox[c] = no;
	}
	for(c = 0; c < arrTbox.length; c++) {
		var no = new Option();
		no.value = arrLookup[arrTbox[c]];
		no.text = arrTbox[c];
		tbox[c] = no;
	}[highlight]
	//  select all in boxToSelect
	for (var x = 0; x < boxToSelect.options.length; x++) {
		boxToSelect.options[x].selected = true;
	}[/highlight]
}
// end -->
</script>

-jeff
try { succeed(); } catch(E) { tryAgain(); } finally { rtfm(); }
i like your sleeves...they're real big
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top