SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    if ($zee == "Guru") { $zee--;}
    Join Date
    Nov 2005
    Location
    Karachi - Pakistan
    Posts
    1,134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    A Question regarding DropDown

    Hi

    I have a HTML form that has a field like this :

    HTML Code:
    <select id="box" name="box">
          <option value="1">Small Box 13x13 with special packing</option>
          <option value="2">Medium Box 16x16 with special packing</option>
          <option value="3">Large Box 20x20 with special packing</option>
    </select>
    Now on the PHP page, I want to access the VALUE of the select field. I.e. 1, 2, 3,
    Please let me know how to get VALUE of the selected item.

    Thanks
    Zeeshan

  2. #2
    SitePoint Evangelist simshaun's Avatar
    Join Date
    Apr 2008
    Location
    North Carolina
    Posts
    438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It depends if the post is submitting via POST or GET, but for example POST would look like this:
    PHP Code:
    echo $_POST['box']; 

  3. #3
    if ($zee == "Guru") { $zee--;}
    Join Date
    Nov 2005
    Location
    Karachi - Pakistan
    Posts
    1,134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am using that but it is showing the TEXT between the <option> </option> not the value.

  4. #4
    SitePoint Evangelist simshaun's Avatar
    Join Date
    Apr 2008
    Location
    North Carolina
    Posts
    438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    post your html and php

  5. #5
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I doubt your drop down box is not properly constructed. So better post your php and html codes here.
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  6. #6
    if ($zee == "Guru") { $zee--;}
    Join Date
    Nov 2005
    Location
    Karachi - Pakistan
    Posts
    1,134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    oh, yes you people are right.

    I do not want to get the value. I want to get the TEXT within the <option></option> thing. Currently it is showing the VALUE. i.e. 1,2,3 but i need the text. Is there a way in PHP to get that ?

  7. #7
    SitePoint Addict Robert_2006's Avatar
    Join Date
    Jun 2006
    Location
    Tarpon Springs Fl.
    Posts
    265
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Change your value to the text you want to recieve. You would have to use javascript to get the option text.

  8. #8
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by zeeshanhashmi View Post
    oh, yes you people are right.

    I do not want to get the value. I want to get the TEXT within the <option></option> thing. Currently it is showing the VALUE. i.e. 1,2,3 but i need the text. Is there a way in PHP to get that ?
    Just do like this in html:
    HTML Code:
    <select id="box" name="box">
          <option>Small Box 13x13 with special packing</option>
          <option>Medium Box 16x16 with special packing</option>
          <option>Large Box 20x20 with special packing</option>
    </select>
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5


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
  •