beechy34 Posted March 24, 2009 Share Posted March 24, 2009 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 More sharing options...
jeffman Posted March 24, 2009 Share Posted March 24, 2009 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 More sharing options...
beechy34 Posted March 25, 2009 Author Share Posted March 25, 2009 how would that work for a radio buttonhere is the code i have i tried the same way as the option but it didnt work. <INPUT TYPE="radio" NAME="PROPTYPE" Value="Freehold" > please help thankyou Link to comment Share on other sites More sharing options...
jeffman Posted March 25, 2009 Share Posted March 25, 2009 Read about the input tag. Radio buttons do not have a selected property, but thay have something like it. If you read about it, you may find what you want: http://www.w3schools.com/tags/tag_input.asp Link to comment Share on other sites More sharing options...
beechy34 Posted March 25, 2009 Author Share Posted March 25, 2009 yeah i found it this is what the code looks like if any one wants it. <INPUT TYPE="radio" NAME="PROPTYPE" Value="Freehold" <?php if ($_POST['PROPTYPE'] == 'Freehold') {echo 'checked="checked"';} ?> Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.