SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Wizard rozner's Avatar
    Join Date
    Oct 2002
    Location
    Paris
    Posts
    1,058
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    selectAll function for list box

    I have two select boxes. One is a collector and the other is items I want to store for later use. Then there is a text input field to add items to the collector and two buttons to switch between the two listboxes.

    This link will make a lot more sense then my attempted explanation:
    http://www.roznet.com/game/test/test2.html

    this form will then POST to a PHP file and I want to have all the items in the left select box in the POST variables. So I have tried writing a javascript function call selectAll() and I this is the function my submit button.
    Code:
    function selectAll(sbox) {
     var i;
     for (i = 0; i < sbox.length; i++) sbox.options[i].select();
    }
     
    <input type="submit" value="Save Changes" onclick="this.disabled=true; selectAll(this.form.cLeftSel); this.form.submit();">
    But this gives this error: Object doesn't support this property or method

    Any help or suggestions on a better way to accomplish this is much appreciated.

  2. #2
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    instead of

    .select();

    use

    .selected = true;
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev





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
  •