SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru
    Join Date
    Aug 2001
    Location
    Amsterdam
    Posts
    788
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    javascript to work with name="list[]"

    I finally got my menu swapper to work in javascript but I have to create a php array..

    This is my code:

    Code:
    <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;
       }
    }
    
    
    function selecteren()
    {
       var o = document.combo_box.list1.options
       for (var i = 0; i < o.length; i++)
      {
        var optie = o[i];
        optie.selected = true;
      }
    }
    //  End -->
    </script>
    and this is how I call it:

    Code:
    <form name="combo_box" action="<?=$PHP_SELF?>" method="GET" OnSubmit="selecteren()">
    <table><tr><td>
    <select multiple size="10" name="list1[]" style="width:150" OnDblClick="move(this.form.list1,this.form.list2)">
    </select>
    </td>
    <td align="center" valign="middle">
    <input type="button" onClick="move(this.form.list2,this.form.list1)" value="<<">
    <input type="button" onClick="move(this.form.list1,this.form.list2)" value=">>">
    </td>
    <td>
    <select multiple size="10" name="list2[]" style="width:150" OnDblClick="move(this.form.list2,this.form.list1)">
    <option value="12">option12</option>
    <option value="54">option54</option>
    <option value="65">option65</option>
    <option value="45">option45</option>
    <option value="2">option2</option>
    </select>
    </td></tr></table>
    <input type="hidden" name="action" value="members" />
    <input type="submit" value="aanpassen" />
    
    </form>
    why won't it work and who can / will fix it

    Greets,

    Peanuts
    the neigbours (free) WIFI makes it just a little more fun

  2. #2
    morphine for a wooden leg randem's Avatar
    Join Date
    Jun 2002
    Location
    .chicago.il.us
    Posts
    957
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this:
    Code:
    <td align="center" valign="middle">
    <input type="button" onClick="move(this.form['list2[]'],this.form['list1[]'])" value="<<">
    <input type="button" onClick="move(this.form['list1[]'],this.form['list2[]'])" value=">>">
    </td>
    ----Adopt-a-Sig----
    Your message here!

  3. #3
    SitePoint Guru
    Join Date
    Aug 2001
    Location
    Amsterdam
    Posts
    788
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Randem,

    You are a Gentleman and a Scholar

    Thats what I've been looking for all day...

    Thanks

    Peanuts
    the neigbours (free) WIFI makes it just a little more fun


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
  •