Just to say, if it doesn't work, watch the word wrap.  There are some long
lines in the script.

Paul

> -----Original Message-----
> From: Paul Johnston [mailto:[EMAIL PROTECTED]]
> Sent: 31 October 2000 17:38
> To: Fusebox
> Subject: RE: Multiple Select Box
>
>
> Got an even better version than before!
>
> This means that you can just keep clicking on "up" to move
> something up and
> the same for down (ie it remembers which one your moving!).
>
> I've also added in some CF so that you can see the data you've just posted
> in the list!
>
> Paul
>
> PS I'll stop doing this now, because it's taking up my time!  It's fun
> though. Maybe I'll make a Netscape version of the code sometime in the
> future!
>
> ----------------page code----------------
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
>
> <html>
> <head>
>       <title>Untitled</title>
> </head>
>
> <body>
>
> <cfset my_js_array = "'Paul', 'Chris', 'Nick', 'Kevin', 'Ian', 'Cat',
> 'John', 'Marc', 'Dean'">
>
> <cfif IsDefined("form.hidden_list")>
>     <cfset my_js_array = "'" & REReplace(form.hidden_list,",", "', '",
> "all") & "'">
> </cfif>
>
> <script language="JavaScript">
> //var values = new Array('Paul', 'Chris', 'Nick', 'Kevin', 'Ian', 'Cat',
> 'John', 'Marc', 'Dean');
> var values = new Array(<cfoutput>#my_js_array#</cfoutput>);
>
> function changeOrder(action) {
>     var form = document.forms[0];
>     check = String(form.order.value);
>     do_update = "yes";
>     if (check.match('^\s*$')) {
>         alert('You have not selected anything!');
>         do_update = "no";
>     }
>     order_value = form.order.value;
>     if (action == 'up' && do_update == 'yes') {
>         //alert('up');
>         if ( order_value == 0) {
>             alert('This value cannot go up any further');
>         }
>         else {
>             // find values of the array
>             swap_value1 = values[order_value];
>             new_order_value = parseInt(order_value) - 1;
>             swap_value2 = values[new_order_value];
>             //alert('order value: ' + order_value + ' new order value: ' +
> new_order_value);
>             //alert('1: ' + swap_value1 + ' 2: ' + swap_value2);
>             // swap them over
>             values[order_value] = swap_value2;
>             values[new_order_value] = swap_value1;
>             // repopulate the array
>             for(i = 0; i < values.length; i++) {
>                 form.order.options[i].value = values[i];
>                 //alert('form.order.options[' + i + ']: ' + values[i]);
>             }
>             refreshSelectBox();
>             form.order.options[new_order_value].selected = true;
>         }
>     }
>     else {
>         //alert('down');
>         if ( order_value == ( values.length - 1 ) ) {
>             alert('This value cannot go down any further');
>         }
>         else {
>             // find values of the array
>             swap_value1 = values[order_value];
>             new_order_value = parseInt(order_value) + 1;
>             swap_value2 = values[new_order_value];
>             //alert('order value: ' + order_value + ' new order value: ' +
> new_order_value);
>             //alert('1: ' + swap_value1 + ' 2: ' + swap_value2);
>             // swap them over
>             values[order_value] = swap_value2;
>             values[new_order_value] = swap_value1;
>             // repopulate the array
>             for(i = 0; i < values.length; i++) {
>                 form.order.options[i].value = values[i];
>                 //alert('form.order.options[' + i + ']: ' + values[i]);
>             }
>             refreshSelectBox();
>             form.order.options[new_order_value].selected = true;
>         }
>     }
>     writeList();
>     // use this if you want to refresh the page!
> }
>
> function writeList() {
>     var form = document.forms[0];
>     form.hidden_list.value = "";
>     for(i = 0; i < values.length; i++) {
>         temp = form.hidden_list.value;
>         if ( i != 0 ) {
>             form.hidden_list.value = temp + ',' + values[i];
>         } else {
>             form.hidden_list.value = values[i];
>         }
>         //alert(form.hidden_list.value);
>     }
> }
>
> function refreshSelectBox(){
>     // values array holds all the relevant data
>     // delete the current select box array
>     var form = document.forms[0];
>     for(i = 0; i < values.length; i++) {
>         // delete the first in the array because we are deleting
> them one by
> one (ie you can't delete the third one if there are only two there)!
>         // alert(form.order.options[0].value);
>         form.order.options[0] = null;
>     }
>     for(i = 0; i < values.length; i++) {
>         newOption = new Option(values[i], i);
>         form.order.options[i] = newOption;
>     }
> }
> </script>
>
> <cfif IsDefined("form.hidden_list")>
>     List Passed To Form: <Cfoutput>#form.hidden_list#</cfoutput><br><br>
> </cfif>
>
> <form method="post" onsubmit="writeList();">
> <script language="JavaScript">
>     document.write('<select name="order" size="' + values.length + '">');
>     refreshSelectBox();
> </script>
> </select>
> <!--- this is to output the array as a list for the next page to take --->
> <input type="hidden" name="hidden_list" value="">
> <input type="Button" value="Up" onclick="changeOrder('up');">
> <input type="Button" value="Down" onclick="changeOrder('down');">
> <input type="submit" value="Finished Ordering">
> </form>
>
> </body>
> </html>
>
>
> ----------------page code----------------
>
> > -----Original Message-----
> > From: Sean Blenkhorn [mailto:[EMAIL PROTECTED]]
> > Sent: 31 October 2000 15:33
> > To: Fusebox
> > Subject: RE: Multiple Select Box
> >
> >
> >
> > I think he means to have a select box with a size of 5 and have
> any number
> > of items in it.... but have the ability to choose one item...
> and move the
> > item up or down in priority.... as if you are ordering sections
> > of a portal
> > site... or ordering the order of jobs in a queue.
> >
> > I don't have the JS to do this.... but it seems easy enough to
> write from
> > scratch.
> >
> > Sean
> >
> >
> > -----Original Message-----
> > From: David Huyck [mailto:[EMAIL PROTECTED]]
> > Sent: Tuesday, October 31, 2000 10:03 AM
> > To: Fusebox
> > Subject: Re: Multiple Select Box
> >
> >
> > Neil--
> >
> > > 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
> >
> > Do you just mean something like:
> > <select name="pickIt" size="1"><options...></select>
> >
> > I'm not sure what you mean by reordering the menu...?
> >
> > David Huyck
> > [EMAIL PROTECTED]
> >
> > ------------------------------------------------------------------
> > ----------
> > --
> > To Unsubscribe visit
> >
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/fusebox or
> send a message to [EMAIL PROTECTED] with 'unsubscribe' in
> the body.
>
> ------------------------------------------------------------------
> ------------
> To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/fusebox or
send a message to [EMAIL PROTECTED] with 'unsubscribe' in
the body.


----------------------------------------------------------------------------
--
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/fusebox or
send a message to [EMAIL PROTECTED] with 'unsubscribe' in
the body.


------------------------------------------------------------------------------
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/fusebox or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to