It's not clear what you're asking for. The subject refers to a multiple
select box, but the message refers to a multiline text menu, whatever
that is. You only want one item visible in a multiple select box?
Doesn't make sense.
Following is some code to move multiple items up and down in a multiple
select element, in case that's what you want.
-David
function move(selElt, dir) {
// Initialize
var errmsg, iOption, iSelOption, iDestOption, limit, offset, selEltLen,
tmpVal, tmpTxt;
var nSelOptions = 0;
var selOptions = new Array();
iSelOption = -1;
selEltLen = selElt.length;
errmsg = "_____________\n\n";
// Determine the selected item(s)
for (iOption=0; iOption<selEltLen; iOption++) {
if (selElt.options[iOption].selected) {
nSelOptions++;
selOptions[nSelOptions-1] = iOption;
}
}
// Set some direction-dependent variables
if (dir == "up") { limit = 0; offset = -1; }
else { limit = selEltLen-1; offset = 1; selOptions.reverse(); }
// Process the selected options
if (nSelOptions == 0) {
errmsg += "No item(s) selected.\n";
errmsg += "_____________\n\n";
alert(errmsg);
} else if (selOptions[0] == limit) {
errmsg += "Cannot move further "+dir+".\n";
errmsg += "_____________\n\n";
alert(errmsg);
} else {
for (iSelOption=0; iSelOption<nSelOptions; iSelOption++) {
iOption = selOptions[iSelOption];
iDestOption = iOption + offset;
tmpTxt = selElt.options[iDestOption].text;
tmpVal = selElt.options[iDestOption].value;
selElt.options[iDestOption].text = selElt.options[iOption].text;
selElt.options[iDestOption].value= selElt.options[iOption].value;
selElt.options[iOption].text = tmpTxt;
selElt.options[iOption].value= tmpVal;
selElt.options[iOption].selected = false;
selElt.options[iDestOption].selected = true;
}
}
}
The function is called by clicking on either an Up or Down arrow gif:
<a href="javascript:move(document.listForm.seItems,'up')"
onMouseover="window.status='Move item(s) up';return true"
onMouseout="window.status='';return true"><img src="images/up.gif"
border="0" title="Move item(s) up"></a>
<br>
<a href="javascript:move(document.listForm.seItems,'down')"
onMouseover="window.status='Move item(s) down';return true"
onMouseout="window.status='';return true"><img src="images/down.gif"
border="0" title="Move item(s) down"></a>
My select element is:
<select name="selItems" multiple size="12">
On Tue, 31 Oct 2000 14:45:20 -0000 "Neil Clark" <[EMAIL PROTECTED]>
writes:
> Okay, second time around.... ;-(
>
> Anyone out there got a script which reorders a multiline text menu?
> for
> instance I have 4 items in it :
>
> 1
> 2
> 3
> 4
>
> I only want 1 select menu visible with an up button and a down
> button, when
> I click the up button it push content up when pusing down - it goes
> down
>
> ??
>
> N
________________________________________________________________
YOU'RE PAYING TOO MUCH FOR THE INTERNET!
Juno now offers FREE Internet Access!
Try it today - there's no risk! For your FREE software, visit:
http://dl.www.juno.com/get/tagj.
------------------------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists or send a message
with 'unsubscribe' in the body to [EMAIL PROTECTED]