Go Back   Dynamic Drive Forums > General Coding > Looking for such a script or service
Search Dynamic Drive Forums:

Reply
 
Thread Tools Search this Thread
  #1  
Old 03-09-2007, 09:31 PM
mdcloud mdcloud is offline
Junior Coders
 
Join Date: Mar 2007
Posts: 51
Thanks: 0
Thanked 0 Times in 0 Posts
Default link to fill in form options ?? is it possible

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
Reply With Quote
  #2  
Old 03-10-2007, 05:40 PM
mdcloud mdcloud is offline
Junior Coders
 
Join Date: Mar 2007
Posts: 51
Thanks: 0
Thanked 0 Times in 0 Posts
Default

does no one know how to do this? possibly a cookie? dont really know. any help would be great

thansk
Reply With Quote
  #3  
Old 03-16-2007, 12:02 AM
mdcloud mdcloud is offline
Junior Coders
 
Join Date: Mar 2007
Posts: 51
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
Reply With Quote
  #4  
Old 03-19-2007, 03:54 PM
aka Robbie aka Robbie is offline
Junior Coders
 
Join Date: Dec 2006
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default

How about using php?

PHP Code:
<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.
Reply With Quote
  #5  
Old 03-21-2007, 03:34 PM
mdcloud mdcloud is offline
Junior Coders
 
Join Date: Mar 2007
Posts: 51
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
Reply With Quote
  #6  
Old 03-22-2007, 01:51 PM
aka Robbie aka Robbie is offline
Junior Coders
 
Join Date: Dec 2006
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Then what you want to do is something like the following:

On your form, where you have your selection, replace it with:
PHP Code:
<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 £ 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:
PHP Code:
<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>

Last edited by aka Robbie; 03-30-2007 at 09:38 AM.
Reply With Quote
  #7  
Old 03-22-2007, 06:35 PM
mdcloud mdcloud is offline
Junior Coders
 
Join Date: Mar 2007
Posts: 51
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
Reply With Quote
  #8  
Old 03-23-2007, 10:08 AM
aka Robbie aka Robbie is offline
Junior Coders
 
Join Date: Dec 2006
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.
Reply With Quote
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:22 AM.

Home - Contact Us - Archives - Link to DD - Top 

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.