SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard
    Join Date
    Dec 2004
    Location
    USA
    Posts
    1,407
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    how to select all options in select box onsubmit?

    I have two select boxes, one with all options where the user can choose some and click a button to move them over to the second select box.

    The problem is I can't process those selected because they are not "selected".

    I need a work-around. I was thinking about using the javascript "onsubmit" event to take all teh options in that second box and select them all.

    How would I do that? Or if there are better options to accomplish this, let me know.

    Many thanks!

    form code:
    HTML Code:
    <SELECT NAME="list11" MULTIPLE SIZE=20 onDblClick="moveSelectedOptions(this.form['list11'],this.form['list21[]'],true)">
    <? echo $calculated_options; ?>
    </SELECT>
    </span>
    <span id="middle">
    <A HREF="#" onClick="moveSelectedOptions(document.forms[0]['list11'],document.forms[0]['list21[]'],false);return false;">&gt;&gt;</A>
    <A HREF="#" onClick="moveAllOptions(document.forms[0]['list11'],document.forms[0]['list21[]'],false); return false;">All &gt;&gt;</A>
    <A HREF="#" onClick="moveSelectedOptions(document.forms[0]['list21[]'],document.forms[0]['list11'],false); return false;">&lt;&lt;</A>
    <A HREF="#" onClick="moveAllOptions(document.forms[0]['list21[]'],document.forms[0]['list11'],false); return false;">All &lt;&lt;</A>
    </span>
    <span id="right">
    <SELECT NAME="list21[]" MULTIPLE SIZE=20 onDblClick="moveSelectedOptions(this.form['list21[]'],this.form['list11'],true)">
    </SELECT>

  2. #2
    SitePoint Addict richtestani's Avatar
    Join Date
    Nov 2003
    Location
    Bridgeport
    Posts
    292
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You want to get the number of form elements,
    Then loop through them all making only checkboxes value true.

    function checkAll() {
    var myFormsLen = document.formName.elements.length;
    for(i=0; i<myFormsLen; i++) {
    if(document. formName.elements[i].type == 'checkbox') {
    document. formName.elements[i].checked = true;
    }
    }
    }

    <a href="#" onclick="checkAll();">Check All</a>
    RichTestani
    -------------------------------
    http://www.junkdepot.com
    http://www.rareoopdvds.com | The Movie Poster Site

  3. #3
    SitePoint Wizard
    Join Date
    Dec 2004
    Location
    USA
    Posts
    1,407
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    terrific - thanks!


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
  •