Thread: Select

    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    31
    Rep Power
    15
    Hi,
    My problem for today is:

    How to select and print the result!

    My HTML
    -------
    <select name="rating" size="1">
    <option name="select[]" value="5">5 - Excellent, Extremely Useful</option>
    <option name="select[]" value="4">4 - Very Good, Useful</option>
    <option name="select[]" value="3">3 - Good, I learned something</option>
    <option name="select[]" value="2">2 - Ok, but not really that useful</option>
    <option name="select[]" value="1">1 - Not Useful At All, Sorry</option>
    </select><input type="submit" value="Submit"></p>
    </form>

    PHP
    ---
    if (sizeof($name) > 0) {
    echo "<br>".implode(",",$select);
    }
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    27
    Rep Power
    0
    Hi Dalida:

    The var $name is not defined in your "select" statement.

    Try changing: if (sizeof($name) > 0)

    ...to...

    if (sizeof($rating) > 0)

    ...not definatively sure that this is the solution. Good luck.

    //ryan
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Location
    Newark, DE, USA
    Posts
    39
    Rep Power
    14
    The html you generate is incorrect. There is no "name=" attribute to the <option> tag in html. It will be ignored, however, by a most html clients & browsers. Once your form is submitted to a php script, the variable $rating will have a value of either 1,2,3,4,or 5. To find out what the user chose on the form, simply:
    echo( "The user chose ".$rating."<br>" );

    ------------------
    ~Chris
  6. #4
  7. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15


    My HTML
    -------
    <select name="rating" size="1">
    <option name="select[]" value="5">5 - Excellent, Extremely Useful</option>
    <option name="select[]" value="4">4 - Very Good, Useful</option>
    <option name="select[]" value="3">3 - Good, I learned something</option>
    <option name="select[]" value="2">2 - Ok, but not really that useful</option>
    <option name="select[]" value="1">1 - Not Useful At All, Sorry</option>
    </select><input type="submit" value="Submit"></p>
    </form>

    PHP
    ---
    if (sizeof($name) > 0) {
    echo "<br>".implode(",",$select);
    }


    Try something like this...

    My HTML
    -------
    <select name="rating[]" size="1">
    <option value="5">5 - Excellent, Extremely Useful</option>
    <option value="4">4 - Very Good, Useful</option>
    <option value="3">3 - Good, I learned something</option>
    <option value="2">2 - Ok, but not really that useful</option>
    <option value="1">1 - Not Useful At All, Sorry</option>
    </select>
    <input type="submit" value="Submit"></p>
    </form>

    PHP
    ---
    if (count($rating[]) > 0) {
    //echo "<br>".implode(",",$rating);
    }


    ------------------
    SR -
    webshiju.com
    www.jobxyz.com-IT Career Portal
    ezipindia.com--WebStudio


    "The fear of the LORD is the beginning of knowledge..."
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2000
    Posts
    79
    Rep Power
    15
    Go with Shiju, except i don't know why you need the var to be an array. There is only one value you need so i suggest simply name="rating"

    If its supposed to be able to have multiple selections try something like...
    <select name="rating" multiple size="3">

    Basil
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    31
    Rep Power
    15
    Everything is working. Thank you!

Similar Threads

  1. Updating text fields from dynamic SQL select box?
    By Trent Hatred in forum HTML Programming
    Replies: 3
    Last Post: February 6th, 2004, 10:34 AM
  2. select verification onsubmit
    By DrStein in forum HTML Programming
    Replies: 3
    Last Post: January 20th, 2004, 03:16 AM
  3. select distinct problem
    By mrengc in forum MS SQL Development
    Replies: 1
    Last Post: December 23rd, 2003, 07:50 AM
  4. Help with javascript, passing multiple select array to js then php
    By zen^Wallhack! in forum JavaScript Development
    Replies: 1
    Last Post: December 3rd, 2003, 01:56 PM
  5. Help with function to copy contents of select item
    By MilesDependent in forum HTML Programming
    Replies: 2
    Last Post: November 23rd, 2003, 06:16 PM

IMN logo majestic logo threadwatch logo seochat tools logo