Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Mar 2008
    Location
    Co.Tyrone, Ireland
    Posts
    80
    Thanks
    8
    Thanked 1 Time in 1 Post

    Passing Information over Link

    Hi everyone,
    I have a dropdown list in a page with a list of products, what I want to do is...

    Have a link e.g. index.php?package=1PageWebsite in a page and I want it to pass through to another page with a dropdown list of products and have the package preselected on the dropdown list.

    Is this possible??

    Hope you can help,

    Thanks
    Donno24

  • #2
    Master Coder mlseim's Avatar
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,381
    Thanks
    8
    Thanked 1,075 Times in 1,066 Posts
    Sure it's possible.

    It would be best if you had a couple of web pages to show us (online).
    One with the link, and the page that has the dropdown list.

    That would give us a better idea of what you're doing.

    The reason to see your page is that there are several ways of doing this,
    but which one is best? Maybe we can answer it best if we see it.
    It could be PHP, Javascripting, and/or both together (AJAX) ... also,
    PHP SESSIONS might be used ... hard to answer right now.

  • #3
    New Coder
    Join Date
    Mar 2008
    Location
    Co.Tyrone, Ireland
    Posts
    80
    Thanks
    8
    Thanked 1 Time in 1 Post
    Sorry I cannot give the website link out at present. But the link is just normal link, and the dropdown is from a page that has this link

    Code:
    orders/mod.php?mod=orders&ord_domain=hello&extension=.ie&Submit=Proceed
    I dunno if this helps any, so sorry for being so vague.

  • #4
    Regular Coder
    Join Date
    May 2008
    Location
    Ohio
    Posts
    231
    Thanks
    3
    Thanked 21 Times in 21 Posts
    That depends on how the dropdown list is generated. If it's from an array in php, this will be very easy. Just compare $_GET['package'] to the current value of the <option> being printed. If it matches, add a 'selected="selected"' option inside of the tag. If it's not the same, display it like normal.

    Some code I just finished writing the other day:

    PHP Code:
    <select name="department">
    <?php
    foreach($departments as $key=>$myrow) {
            echo (
    $myrow['id'] == $row['dep']) ? '<option value="'.$myrow['id'].'" selected="selected">'.$myrow['name'].'</option>' '<option value="'.$myrow['id'].'">'.$myrow['name'].'</option>';
    }
    ?>
    </select>
    More simplistically:
    PHP Code:
    <select name="department">
    <?php
    foreach($departments as $key=>$myrow) {
            if(
    $myrow['id'] == $row['dep']) {
                    echo 
    '<option value="'.$myrow['id'].'" selected="selected">'.$myrow['name'].'</option>';
            } else {
                    echo 
    '<option value="'.$myrow['id'].'">'.$myrow['name'].'</option>';
            }
    }
    ?>
    </select>
    Last edited by derzok; 08-04-2008 at 04:19 PM.
    zok@zoklet:~$ whereis zok
    zok: http://zoklet.net | http://zoklet.net/otg | /derzok/at/gmail/dot/com


  •  

    Posting Permissions

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