#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    2
    Rep Power
    0
    I am setting up a "links" page on our intranet site at work.

    I'm setting it up to where links pertaining to the same subject are grouped in a form drop-down box, with a "GO" button next to the drop-down box.

    The "go" button sends the url to a link.php3 and it redirects the user to the desired page.

    I currently have only one drop-down box and here lies my question:

    How can I determine in my php script what drop-down box they used?

    I could go the easy/messy route and make a link1.php3, link2.php3, etc... for each drop-down box, but I don't want to do that...

    Could I hide an input field and use javascript or something to put a number in it to tell my php3 script which drop-down box to get the url from?

    Thanks for any assistance, just learning php3, as you can tell...
  2. #2
  3. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    Perth West Australia
    Posts
    757
    Rep Power
    15
    You could give each drop down a name <select name=drop1> etc .... errr or

    name each submit button seperately ie <input type=submit name=dd1 value=go> and then test for if($dd1) as opposed to if($submit) -

    not sure if I am thinking what you are thinking...

    Simon.

    ------------------
    Simon Wheeler
    FirePages -DHTML/PHP/MySQL
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    45
    Rep Power
    15
    As the previous post said, give each selection box a name corresponding to what url you want to redirect them to. Then, when they hit submit, you can just determine what url they want, without messing with what box they chose. I think I'm thinking what you're think, and if I'm not/this isn't helpful then please explain yourself more...
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    2
    Rep Power
    0
    Thanks, that works great...

    I named each button go1, go2, etc...

    in my link.php3, I have:

    if ($go1)
    {
    header("Location: $link1)
    }
    else
    {
    if ($go2)
    {
    header("Location: $link2)
    }
    }

    etc...


    $go1 & $go2 are my two "go" submit buttons
    $link1 & $link2 are my two drop-down boxes...


    again, thanks guys...
  8. #5
  9. No Profile Picture
    Dave Bryant
    Guest
    Devshed Newbie (0 - 499 posts)
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by RodZilla:
    Thanks, that works great...

    I named each button go1, go2, etc...

    in my link.php3, I have:

    if ($go1)
    {
    header("Location: $link1)
    }
    else
    {
    if ($go2)
    {
    header("Location: $link2)
    }
    }

    etc...


    $go1 & $go2 are my two "go" submit buttons
    $link1 & $link2 are my two drop-down boxes...


    again, thanks guys...
    [/quote]

    One slightly more efficient and less painful to follow set of rules to use instead of if statements is the Switch Statement. This allows you to pass a variable and compare it against several criteria or a default. If none of the criteria are met then it takes you to a predetermined default.
    Here I use code to check for a certain form element and output a color
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    function moveurl ($move) {

    $move_arr = array("modem", "dsl", "hosting");
    switch ($move) {
    case "modem":
    $referer = "modem_order.phtml";
    case "dsl":
    $referer = "dsl_order.phtml";
    case "hosting":
    $referer = "hosting_order.phtml";
    }
    header("Location: $referer");
    [/code]
    This is an example of a script i wrote at work which allows you to set the header location based upon what the name of the referring page. You can modify this to fit what you are doing.
    Switches are neat and clean.
    Give them a try.

    ------------------
    --Dave Bryant
    dbryant@jump.net
    dbryant@waterloobay.com

Similar Threads

  1. URL with bookmark on close spawns multiple pop up windows
    By Lalita in forum Beginner Programming
    Replies: 4
    Last Post: February 3rd, 2004, 11:11 PM
  2. URL parameter with multiple values
    By astroe in forum PHP Development
    Replies: 10
    Last Post: February 2nd, 2004, 08:13 AM
  3. How to pass multiple url variables
    By yoz in forum HTML Programming
    Replies: 2
    Last Post: January 28th, 2004, 11:21 AM
  4. Implementing multiple linked lists in same program
    By habit in forum C Programming
    Replies: 4
    Last Post: December 25th, 2003, 11:59 PM
  5. Tricky query with multiple mailing lists
    By John Cook in forum MySQL Help
    Replies: 1
    Last Post: October 29th, 2003, 01:49 PM

IMN logo majestic logo threadwatch logo seochat tools logo