Cheers, thanks for that.

Whilst looking around I found the following via google which seems to work nicely.

Thanks

Dave

<script>
function move(foo,way) { j=-1; menuLen=foo.length;
if (way=='up') { lim=0; m=-1 } else { lim=menuLen-1; m=1 };
for (i=0;i<menuLen;i++) if (foo.options[i].selected) { j=i; i=menuLen; }
if (j==-1) alert('You have nothing selected.'); else if (j==lim) alert('You can\'t go '+way+' any further.')
else { k=j+m; tempt=foo.options[k].text; tempv=foo.options[k].value;
foo.options[k].text=foo.options[j].text
foo.options[k].value=foo.options[j].value
foo.options[j].text=tempt; foo.options[j].value=tempv;
foo.options[j].selected=false;
foo.options[k].selected=true; } }
function showMenu(foo) { temp=''; menuLen=foo.length; comma=''
for (i=0;i<menuLen;i++) { j=i+1; temp += comma + foo.options[i].value; comma=',' }
document.theForm.theResults.value=temp
}
</script>


<form name=theForm action="newList.cfm" method="post" onSubmit="showMenu(document.theForm.theMenu)">
<p><a href="javascript:move(document.theForm.theMenu,'up')">up</a></p>


<cfoutput><input type=hidden name=theCount value="#getcontent.recordcount#"></cfoutput>

<input type=hidden name=theResults value="">

<p>
<select name="theMenu" size="10"></cfoutput>
<cfoutput query=getcontent>
<option value="#contentid#">#contentseq# - #contentname#</option>
</cfoutput>
</select>
</p>
<p><a href="javascript:move(document.theForm.theMenu,'down')">down</a></p>


<p><input type=submit name=submit value="rearrange"></p>
</form>

At 9/29/2003 14:12, you wrote:
here you go...

Create a Hidden form field thus :

<input type="hidden" name="linkorderlist" value="">




<!--- select box script, this will allow the user to reorder the list as and when required ---> <script type="text/javascript"> <!--

// NOTE : linkList is your select list, you could use the argument, but I
cant be arsed.

function moveEmLinks(direction,listname) {

        if (listname == 'select2') {
                dfr = document.forms[0].linkList;
        }

        boxLen = dfr.length;
        currentItem = dfr.selectedIndex;

        if ((direction == 'up') && (currentItem > 0)) {
                //reorder the text
                selText = dfr.options[currentItem].text;
                swpText = dfr.options[currentItem - 1].text;

                // reorder the value
                selValue = dfr.options[currentItem].value;
                swpValue = dfr.options[currentItem - 1].value;

                //reorder the text
                dfr.options[currentItem - 1].text = selText;
                dfr.options[currentItem].text     = swpText;

                // reorder the value
                dfr.options[currentItem - 1].value = selValue;
                dfr.options[currentItem].value    = swpValue;

                dfr.selectedIndex = currentItem - 1;
                // writeList();

        } else if ((direction == 'down') && (currentItem < boxLen - 1) &&
(currentItem != -1)) {
                selText = dfr.options[currentItem].text;
                swpText = dfr.options[currentItem + 1].text;

                // reorder the value
                selValue = dfr.options[currentItem].value;
                swpValue = dfr.options[currentItem + 1].value;

                //reorder the text
                dfr.options[currentItem + 1].text = selText;
                dfr.options[currentItem].text     = swpText;

                //reorder the value
                dfr.options[currentItem + 1].value = selValue;
                dfr.options[currentItem].value    = swpValue;

                dfr.selectedIndex = currentItem + 1;
                // writeList();

        } else if (currentItem == -1) {
                alert("One Link must be selected before it can be
reordered.");

        } else {}
}


function writeList() { alertText = "";

        // these ensure the length is always declared
        dfr = document.forms[0].linkList;
        boxLen = dfr.length;

        for (i=0;i<boxLen;i++) {
                // value does not work as the list is effectively unchanged
                alertText = alertText + dfr.options[i].value+ ",";

}

        //alert(alertText);
        document.forms[0].linkorderlist.value = alertText;

}

//-->
</script>


Call it : href="javascript:moveEmLinks('up','linkList');"


or href="javascript:moveEmLinks('down','linkList');"


Same procedure are usual for submitting : you will have to select all and then submit it.




-----Original Message----- From: Dave Phipps [mailto:[EMAIL PROTECTED] Sent: 29 September 2003 14:09 To: ColdFusion User group Subject: [ cf-dev ] Select Box Reorder


Hi,


I have the following javascript which basically allows a select list to be
reordered.  The original JS place the reordered list into a query string
but I want to place it into a hidden form field.  I can get the hidden
field to populate but it never changes the order when then select box is
changed:

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function move(index,to) {
var list = document.navOrder.list;
var total = list.options.length-1;
if (index == -1) return false;
if (to == +1 && index == total) return false;
if (to == -1 && index == 0) return false;
var items = new Array;
var values = new Array;
for (i = total; i >= 0; i--) {
items[i] = list.options[i].text;
values[i] = list.options[i].value;
}
for (i = total; i >= 0; i--) {
if (index == i) {
list.options[i + to] = new Option(items[i],values[i + to], 0, 1);
list.options[i] = new Option(items[i + to], values[i]);
i--;
}
else {
list.options[i] = new Option(items[i], values[i]);
    }

}
list.focus();
}
function submitForm() {
var list = document.navOrder.list;
var menuids = "";
var theList = "";
for (i = 0; i <= list.options.length-1; i++) {
theList += list.options[i].value;
menuids += list.options[i].value;
// a "," only BETWEEN the items, so not at the end
if (i != list.options.length-1) theList += ",";
if (i != list.options.length-1) menuids += ",";
}
document.navOrder.menuids.value = menuids;
document.navOrder.submit();
}
//  End -->
</script>

Anyone help with getting the reorder list into a hidden field?

Cheers

Dave


-- ** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/

To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
For human help, e-mail: [EMAIL PROTECTED]

--
** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/

To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
For human help, e-mail: [EMAIL PROTECTED]


--
** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/

To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
For human help, e-mail: [EMAIL PROTECTED]



Reply via email to