please how can i create a form with three drop down list menu and when submit button is clicked it return a result depending on the choice made from the drop down menu

Recommended Answers

All 2 Replies

Ok, so you will need three HTML <select> tags and an <input type='submit'> tag placed inside a <form> tag in your HTML page. In your PHP, you can use the $_POST array to retrieve posted data like so:

if( isset( $_POST[ "first_select" ]))
{
  $first_selection = $_POST[ "first_select" ];
  // assuming the name of your first <select> tag is "first_select"
}
else
{
  $first_select = false;
  // or some other default value
}

You will probably need to validate the data that has been posted, regular expressions are often useful for this purpose.

Have a go and if you have any more questions please don't hesitate to ask. :)

Good luck,
d

<?php if($_POST){
echo 'submitted were<br>';
foreach ($_POST as $key => $value) {
echo $key." value ".$value.'<br>';} }
?>
<form action='<?php echo $_SERVER['php_self']; ?>' method='post'>
choice 1<select name='1'>
<option value='big'> big</option>
<option value='blue'> blue</option>
<option value='marble'> marble</option>
</select> &nbsp;
choice 2<select name='2'>
<option value='big'> big</option>
<option value='blue'> blue</option>
<option value='marble'> marble</option>
</select> &nbsp;
choice 3<select name='3'>
<option value='big'> big</option>
<option value='blue'> blue</option>
<option value='marble'> marble</option>
</select><br>
Is AlmostBob a smartass<input type='radio' value='yes' checked='checked' name='radio'> Yes <input type='radio' value='no' name='radio'> No<br>
<button TYPE="submit" name="submit" value="submit" onclick="return(confirm('Are you sure,\nthis is such a **example'));">Submit</button> one kind of submit button<br>
<input type='submit' onclick="return(confirm('Are you sure you want \nto destroy all life?'));" value='exterminate'> another kind of Submit button<br>
</form>

How many forms do you want to know how to build
or should you just go to the w3c tutorial page at http://www.w3.org/TR/html401/interact/forms.html

commented: Haha, I particularly like the 'Exterminate' submit button :) +3
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.