How to pick values from the list box using php?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • santhanalakshmi
    New Member
    • May 2009
    • 147

    How to pick values from the list box using php?

    Hi,
    Code:
    [B]while($row = mysql_fetch_array($result))
    $rows[] = $row['crseid'];
    print "<td>";
    print "<select name='ccrseid'>";
    foreach($rows as $row)
    { 
         echo "<option value='$row' selected>$row</option>";
    
    }
    print "</select>";
    print "</td>";
    [/B]
    Always, i am getting the last values. I can't retrieve the remaining values. Without $_POST[] ARRAY,how i can print the select option values without by clicking "submit" button and once by changing the select option values, and the values in the text box should gets changed. Thanks in advance
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    your question is a bit confusing, what does this code have to do with a submit?

    Comment

    • santhanalakshmi
      New Member
      • May 2009
      • 147

      #3
      Hi,
      whenever i changing (or picking) the value from the select option.....i need the picking value as my output. But i am only getting the last value from the array.

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        the selected attribute must be only once in a select field (unless you have a multiple select).

        Comment

        • santhanalakshmi
          New Member
          • May 2009
          • 147

          #5
          I can't get you.Please give some more explanation

          Comment

          • Dormilich
            Recognized Expert Expert
            • Aug 2008
            • 8694

            #6
            you have the selected attribute in every <option> element of the <select>, thus the last one is selected by default.

            Comment

            • santhanalakshmi
              New Member
              • May 2009
              • 147

              #7
              if the last one only is selected by default means...then what is the use for this drop down box(or select option)and how we can able to handle multiple values

              Comment

              • Dormilich
                Recognized Expert Expert
                • Aug 2008
                • 8694

                #8
                add the multiple attribute to the <select>

                Comment

                • santhanalakshmi
                  New Member
                  • May 2009
                  • 147

                  #9
                  what function will done by "multiple" attribute?

                  Comment

                  • Dormilich
                    Recognized Expert Expert
                    • Aug 2008
                    • 8694

                    #10
                    (from http://www.w3.org/TR/html401/interact/forms.html#h-17.6)
                    multiple [CI]
                    If set, this boolean attribute allows multiple selections. If not set, the SELECT element only permits single selections.
                    to cite the standard …

                    Comment

                    Working...