Results 1 to 8 of 8

Thread: link to fill in form options ?? is it possible

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

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

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

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

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

  6. #6
    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 &#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:
    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 08:38 AM.

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

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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •