HTML SELECT multiple VALUES?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jeremyjcochran
    New Member
    • Dec 2008
    • 3

    HTML SELECT multiple VALUES?

    I am writing a code for a shopping cart, the customer selects the color, which also has the price. I want to send the color and the price to "price" and "color" on the mysql server. How do I code a SELECT to send two different variables to two different mysql names?

    I have this right now....

    Code:
              echo "<select name='priceBox' name2='colorBox'>";
    
                 echo "<option value='" . $prodrow['price'] . "' value2='" . Black . "'>Black $" . $prodrow['price'] . "</option>";
                 echo "<option value='" . $prodrow['price2'] . "' value2='" . White . "'>White $" . $prodrow['price2'] . "</option>";
                 echo "<option value='" . $prodrow['price3'] . "' value2='" . None . "'>No Paint $" . $prodrow['price3'] . "</option>";
    
             echo "</select>";
    It doesn't work, so I want to know if there is a way to do this... thank you.
  • drhowarddrfine
    Recognized Expert Expert
    • Sep 2006
    • 7434

    #2
    Simple answer. You can't.

    Comment

    • TheServant
      Recognized Expert Top Contributor
      • Feb 2008
      • 1168

      #3
      One way you can do it is do the work where the form is submitted to. So have your value (you can only have one) as "option 1" or something and then include in your form processing code something like:
      Code:
      if ( $_POST['priceBox'] == "option 1" ) {
      $price = $prodrow['price'];
      $color = "black"
      } elseif  ( $_POST['priceBox'] == "option 1" ) {
      ...
      }
      Just remember html forms are really just text, so you need to do the work in javascript or PHP. Another way would be to have a hidden input box and then use javascript to change the value of it as the user selects a different option. There are hundreds of other ways I am sure, but as drhowarddrfine said, not that way.

      Comment

      • Bharat383
        New Member
        • Aug 2011
        • 93

        #4
        <SELECT ID="Select1" NAME="Select1" multiple="multi ple">
        <OPTION VALUE="1">1</OPTION>
        <OPTION VALUE="2">2</OPTION>
        <OPTION VALUE="1">1</OPTION>
        <OPTION VALUE="2">2</OPTION>
        <OPTION VALUE="1">1</OPTION>
        <OPTION VALUE="2">2</OPTION>
        <OPTION VALUE="1">1</OPTION>
        <OPTION VALUE="2">2</OPTION>
        <OPTION VALUE="1">1</OPTION>
        <OPTION VALUE="2">2</OPTION>

        </SELECT>

        Comment

        Working...