Hello all,
I'm a newbie at php and have had a blast learning the little i have so far. I've been trying to incorporate more and more php forms into the sites i'm building and would love to build a more 'complex' form on my next project.
I'd like setup a contact form of sorts, but would like a different form to be displayed based on user input. To start, have a look at this:
<?php
if ($_POST['submit'] == true) {
echo "Message Sent";
} else {
?>
<form name="form2" method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<table border="0" cellspacing="0" cellpadding="2">
<tr>
<td>Name:</td>
<td><input type="text" name="name" /></td>
</tr>
<tr>
<td>Email:</td>
<td><input type="text" name="email" /></td>
</tr>
<tr>
<td>What are you inquiring about?</td>
<td><select name="inquiryType">
<option>Option 1</option>
<option>Option 2</option>
<option>Option 3</option>
<option>Option 4</option>
</select>
</td>
</tr>
<tr>
<td> </td>
<td valign="top"><input type="submit" name="submit" value="Send Form" /></td>
</table>
</form>
<?php
}
?>
I'd like to have different forms displayed based on the option the user chooses form the drop down list. How can this be done?
Also, is there a way to have the drop down list pass its variable without having the submit button? In other words, can the form relating to the option the user selects be displayed automatically without the user clicking submit?
Thanks in advance!