PDA

View Full Version : link to fill in form options ?? is it possible



mdcloud
03-09-2007, 08:31 PM
hey guys,

i have been searching a while without luck. what i am wanting to do is have a form. in that form will be a drop down menu of locations to register for. i want to click a link to that page and have the drop down on the appropriate spot in the drop down sort of like a target. is there a way to do it.

really appreciate all the help this site has given me over the last couple of years

brent

mdcloud
03-10-2007, 04:40 PM
does no one know how to do this? possibly a cookie? dont really know. any help would be great

thansk

mdcloud
03-15-2007, 11:02 PM
is this such an unusual request? i didnt think this was that complicated of a problem. i guess i can have different forms for each option to fill in the location i need, but that means like 50 forms to accomplish what i though was a simple problem

aka Robbie
03-19-2007, 02:54 PM
How about using php?



<select name="location">
<option selected>PLEASE SELECT</option>
<?php
$location =$_GET['loc'];

if ($location == "a") {
echo '<option value="a" selected>a</option>';
}
else
echo '<option value="a" selected>a</option>';

if ($location == "b") {
echo '<option value="b" selected>b</option>';
}
else
echo '<option value="b" selected>b</option>';
?>
</select>


Now depending upon the variable when entering the page the form will display the correct option in the drop down.

mdcloud
03-21-2007, 02:34 PM
i am not sure how to make that work. ok here is a link to the first page where i want people to choose a seminar to attend

www.beinhealth.com/test/fmlftlsched.html

now a user will click on the fml or ftl or kids link to register for that seminar. i do not know how to make the form know which one the clicked on

thanks for any help you can give

aka Robbie
03-22-2007, 12:51 PM
Then what you want to do is something like the following:

On your form, where you have your selection, replace it with:

<select name="location">
<option>PLEASE SELECT</option>
<?php
$type =$_GET['type'];

if ($type == "fml") {
echo '<option value="fml" selected>fml</option>';
}
else
echo '<option value="fml">fml</option>';

if ($type == "ftl") {
echo '<option value="ftl" selected>ftl</option>';
}
else
echo '<option value="ftl">ftl</option>';

if ($type == "kids") {
echo '<option value="kids" selected>kids</option>';
}
else
echo '<option value="kids">kids</option>';
?>
</select>

Save your form as a php file.

Now in the page that calls the form, for the links put:
<form>.php?type=fml
<form>.php?type=ftl
<form>.php?type=kids
depending on which option you want selected when the form is shown.

I've actually been working on something similar. Here is my page:
http://www.metadigm.co.uk/partners/websense/index.php

If you click on the "get a free quote" in the "resources" section you will notice that next to "Product" it states "Please State". Pretty much a normal form. However if you click on the &#163; icon under each product you will see that the drop-down automatically selects the correct product. This is all done in the same form using the method above.

And here's the code for that select:

<select name="product">

<?php
$prod =$_GET['prod'];

if ($prod == "gen") {
echo '<option selected>Please state</option>
<option value="Websense in general">Websense in general</option>';
}
else
echo '<option>Please state</option>
<option value="Websense in general">Websense in general</option>';

if ($prod == "ent") {
echo '<option selected value="Websense Enterprise">Websense Enterprise</option>';
}
else
echo '<option value="Websense Enterprise">Websense Enterprise</option>';

if ($prod == "cpm") {
echo '<option selected value="Client Policy Manager">Client Policy Manager</option>';
}
else
echo '<option value="Client Policy Manager">Client Policy Manager</option>';

if ($prod == "wss") {
echo '<option selected value="Web Security Suite">Web Security Suite</option>';
}
else
echo '<option value="Web Security Suite">Web Security Suite</option>';
?>

</select>

mdcloud
03-22-2007, 05:35 PM
Thank you Thank you Thank you

that works great. i have never really learned much php but it looks like i need to. thanks for your help. i like your site btw.

brent

aka Robbie
03-23-2007, 09:08 AM
I didn't know much php until a few months ago when I started using this site more.

Now here's a big tip for you. From now on, each page save as php and not html. It will make life a life easier when you create links.

Why, because you will discover just what php can do for you and you will start using it more and more. It will be a right PITA having to go back and change your links.

I use php a lot now with variables. So now depending on where a person has come from depends on what they see on the page.