Jump to content

Form


beechy34
 Share

Recommended Posts

hi what i have done is created a form with data validation i have put form in the php file as well so it can tell if i have put say number where test should be in name, so if put a number it will show up with an error message by the text field and if the data in the text field is correct then the data will stay there here is the code for what i have done if you dont know what i am getting at:-

Telephone:<br><input type="text" size=40 name="TELEPHONE" value= "<?php echo $phone; ?>"><br>

what i would like to know is how would i do that for an option box, here is an example of one of my option boxes if that is what they are called:-

<SELECT NAME = "HOUSE" multiple><OPTION VALUE="Terrace"  > Terrace<OPTION VALUE="Semi-Detached"> Semi-Detached<OPTION VALUE="Detached"> Detached</SELECT>

please can you help me with thisthankyou

Link to comment
Share on other sites

The most simple technique looks like this:<option value="Terrace" <?php if ($_POST['HOUSE'] == 'Terrace') {echo 'selected="selected"';} ?>>Terrace</option>This will work, and if you only have a few tags, it will be okay. If you have many tags, you might want to automate the system with loops and arrays.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...