1

Im using a drop down menu in a contact form,

option 1 : Worldwide Cover
option 2 : European Cover

But that form is inserted into a DB, which is then read by ?id,

is there any way to have a value for each dropdown, for example if they select "option one" it will input the terms for worldwide cover to the DB,

if they select option 2 it will input terms for europe into the DB

1
  • 1
    If you want the form to pass the text from the option tags, you'll need to use the text as the option values. <option value='Worldwide Cover'>Worldwide Cover</option> Or, if those values come from a database and you're inserting into that database, just insert the numeric values, since you can JOIN to query them. That's what database normalization is all about. Commented Apr 7, 2012 at 14:17

2 Answers 2

2

Like this:

<option value="your_value">Some label</option>
<option value="another_value" selected>Another label</option>

The selected attribute is to make it selected by default (when the form is first shown to the user), which seems to be what you are asking about in the question title.

Sign up to request clarification or add additional context in comments.

2 Comments

yes and if they select "some label" it will input "your_value" into the DB?
That's not possible. The value property must be a string. You must have the value as a reference to an image, such as the filename or similar.
0
          <?php
             $option_value=$_POST['select_value'];
            echo  $option_value;
          ?>
  DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org  /TR/xhtml1/DTD/xhtml1-transitional.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml">
   <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
     <title>Entry_form</title>

     </head>
      <body>
       <form action="" method="post" >
       <select name="select_value">

        <option value="Worldwide Cover">option1</option>
        <option value="European Cover">option2</option>
        </select>
         <input type="submit" value="submit" />
          </form>
         </body>
       </html>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.