Reputation: 23
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
Upvotes: 1
Views: 387
Reputation: 884
<?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>
Upvotes: 0
Reputation: 13331
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.
Upvotes: 2