Jump to content

pre select form option through link


damiancds
 Share

Recommended Posts

is it possible to have a link to a page with a form on it and change one of the options in a select box from that link?ie<a href="page01.php" id(select_01).value(3)>blah</a>basically I have a contact form for every type of contact, and I have a link to submit a question, and if they click that link, I want the 3rd option of the select box to show instead of the first default optionis it possible?thanks,

Link to comment
Share on other sites

Not quite sure, if i get exactly what you want? this below send the id ref to the form select, if the id matches id reference from table output, it assigns selected="selected" to the option list, else echo normal option<a href="page01.php?id=3">blah</a><select><?phpwhile ($row = mysql_fetch_assoc($result)) { if($_GET['id'] == $row['id']) {echo '<option value="'.$row['id'].'" selected="selected">'.$row["contact"].'</option>'; }else{echo '<option value="'.$row["id"].'">'.$row["contact"].'</option>';} }?></select>

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...