Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jan 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Select Box POSTing

    I have two select boxes I can Add and Remove the different Options between each of the select boxes. I am trying to submit this form and get all of the values of the Select box that I am adding to. Unfortunately I can't seem to get the information in the select box to go from one form to another. On the second form I use the $test = _POST['test'];. This works for all of the other types of form controls (text box, text area, checkbox, radio, etc), but not with the select box. Am I missing something?

    I am using this format for the select box.

    <select muliple=1 name=test><option></option><option></option></select>

    Thanks

  • #2
    New to the CF scene
    Join Date
    Jan 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Update - Fixed

    I ended up using hidden fields to save the value from the select box.

    Thanks

  • #3
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    you should use the post method, its much better as it wont require JavaScript (which is I'm assuming what you did). You have to do multiple select fields differently...

    Code:
    <form action="file.php" method="post">
    <select name="test[]" multiple="multiple">
    <!-- Notice the [] after the name -->
      <option value="test1">test 1</option>
      <option value="test2">test 2</option>
    </select>
    </form>
    PHP Code:
    <?php

    $test 
    $_POST['test'];
    for(
    $i=0$i<count($_POST['test']); $i++ ){
      echo 
    $test[$i] . "<br />";
    }

  • #4
    New to the CF scene
    Join Date
    Jan 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks,

    I did end up using javascript, took me a while because I kept mixing up my PHP and Javascript syntax. But I think the code you just listed will come in very handy. I wanted to use PHP as my solution in the first place.


  •  

    Posting Permissions

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