#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    27
    Rep Power
    0
    Hi:

    I'm writing a form with a "select" window called "choices" and when I send the form data to the next page, I end up with the last value selected in "choices."

    I know that multiple selects are stored as arrays, but my problem is that PHP is only showing the last array element.

    Ideas?

    Here's the basic form code:
    ...
    <form name="list" action="./print.php3" method=get >

    <select name='choices' multiple size=10>
    <option>hi</option>
    <option>there</option>
    <option>dude</option>
    </select>
    <input type=submit>
    </form>
    ...


    Thanks
    //ryan
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jul 2000
    Posts
    669
    Rep Power
    15
    You need to declare the for element being an array in your form like this


    <?php
    if ($submit) {

    while (list ($key, $val) = each ($choices)) {
    print $val ."<br>";
    }
    exit;
    }
    ?>

    <form name="list" action="<?php print $PHP_SELF; ?>" method=post>
    <select name="choices[]" multiple size=10>
    <option>hi</option>
    <option>there</option>
    <option>dude</option>
    <option>monkey</option>
    </select>
    <input type=submit name=submit>
    </form>

Similar Threads

  1. pdf forms?
    By bellcom in forum Web Design Help
    Replies: 0
    Last Post: January 31st, 2004, 10:08 PM
  2. One confirmation email, two different forms
    By sisleysusie in forum PHP Development
    Replies: 3
    Last Post: January 26th, 2004, 11:26 PM
  3. Putting/submitting lots of forms on one page
    By rampguy in forum PHP Development
    Replies: 1
    Last Post: December 5th, 2003, 11:47 PM
  4. Dynamic forms that change by user interactions?
    By BassPlayer in forum PHP Development
    Replies: 4
    Last Post: April 4th, 2003, 04:05 AM
  5. Those Evil forms
    By Ricochet in forum HTML Programming
    Replies: 1
    Last Post: August 28th, 2001, 12:44 PM

IMN logo majestic logo threadwatch logo seochat tools logo