SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Member ongardie's Avatar
    Join Date
    Aug 2003
    Location
    The Woodlands, TX
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Select Box Order

    I'm making a page with a form for my users to move around "modules" for their welcome screen. I have the moving from box to box worked out but I can't get the vertical orders to work. I am new to Javascript so much of my code is probably very inefficient.

    This is the test page as of August 16, 2003

    I can get the items to move visually but I don't know how to get them to move as the code sees it.

    Any help will be appreciated as I am very new to all of this. I have managed to get this far by taking parts of other scripts and by asking for help.

  2. #2
    011521 dbalsdon's Avatar
    Join Date
    Feb 2003
    Location
    North Of Scotland
    Posts
    444
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ongardie
    I have the moving from box to box worked out but I can't get the vertical orders to work.
    If you are talking about rearranging the order of the items as we see it vertically... then it works for me... i can move all the items from left to right.. and make the move up and down in the left and right boxes...
    Daniel Balsdon
    My Site

  3. #3
    SitePoint Guru Vincent Puglia's Avatar
    Join Date
    Feb 2000
    Location
    where the World once stood
    Posts
    700
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    I also am not certain of what you mean; however why do you have the code I cancelled out?
    Code:
     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]);
    //	 }
     }
    if you place the following alert at its end -- before the list.focus() statement, both with and without the cancelled code -- you will see why I ask:
    for (var i = 0; i < list.length; i++)
    alert('values= ' + list.options[i].value + ' text= ' + list.options[i].text)

    Vinny
    Where the World Once Stood
    the blades of grass
    cut me still

  4. #4
    SitePoint Member ongardie's Avatar
    Join Date
    Aug 2003
    Location
    The Woodlands, TX
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you are talking about rearranging the order of the items as we see it vertically... then it works for me... i can move all the items from left to right.. and make the move up and down in the left and right boxes...
    It works visually. That's not the problem. The problem is that it doesn't send the information in the proper visual order.


    Vinny, I will try this however I have little time to work on it today. That code is what changes the order but there may be a better way of doing it (I only optimized it, didn't write it).

    Sorry I was not clear the first time around but thanks for the help.

  5. #5
    SitePoint Guru Vincent Puglia's Avatar
    Join Date
    Feb 2000
    Location
    where the World once stood
    Posts
    700
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    I have little time to work on it
    ditto. However, when I played with it yesterday, that section seemed to be the culprit. I moved 2 options to the left, then moved the second up to the first position. The alert I posted showed that each had the other's value (or text, don't remember which).

    Also, consider sending the form object as well as the list/direction/etc. as in: vertical('sub[]',-1,this.form)

    It makes the code more readable
    formObj.elements[list]
    instead of
    document.formname.elements[list]
    and eliminates the need for the eval(...)

    Vinny
    Where the World Once Stood
    the blades of grass
    cut me still

  6. #6
    SitePoint Member ongardie's Avatar
    Join Date
    Aug 2003
    Location
    The Woodlands, TX
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the advice Vinny. I will change that on readability and I will look for another method of changing the vertical order.

  7. #7
    SitePoint Evangelist Mr. Brownstone's Avatar
    Join Date
    May 2002
    Location
    Relative
    Posts
    452
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I wrote a similar script a while back, which you can find on my home-page.

    The methods it uses to submit form information (using hidden fields) and also to re-order items should help you out.
    Of course, that's just my opinion. I could be wrong.

  8. #8
    SitePoint Guru Vincent Puglia's Avatar
    Join Date
    Feb 2000
    Location
    where the World once stood
    Posts
    700
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Along Mr.Brownstone's vein, see the "Reordering Selects" scripts/tutorials at my site (GrassBlade).

    Vinny
    Where the World Once Stood
    the blades of grass
    cut me still


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •