Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-04-2008, 03:42 PM   PM User | #1
Donno24
New Coder

 
Join Date: Mar 2008
Location: Co.Tyrone, Ireland
Posts: 80
Thanks: 8
Thanked 1 Time in 1 Post
Donno24 is an unknown quantity at this point
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
Donno24 is offline   Reply With Quote
Old 08-04-2008, 03:48 PM   PM User | #2
mlseim
Master Coder

 
mlseim's Avatar
 
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,055
Thanks: 8
Thanked 1,032 Times in 1,023 Posts
mlseim has a spectacular aura aboutmlseim has a spectacular aura aboutmlseim has a spectacular aura about
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.
mlseim is offline   Reply With Quote
Old 08-04-2008, 04:06 PM   PM User | #3
Donno24
New Coder

 
Join Date: Mar 2008
Location: Co.Tyrone, Ireland
Posts: 80
Thanks: 8
Thanked 1 Time in 1 Post
Donno24 is an unknown quantity at this point
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.
Donno24 is offline   Reply With Quote
Old 08-04-2008, 04:17 PM   PM User | #4
derzok
Regular Coder

 
Join Date: May 2008
Location: Ohio
Posts: 231
Thanks: 3
Thanked 21 Times in 21 Posts
derzok is an unknown quantity at this point
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>
__________________
zok@zoklet:~$ whereis zok
zok: http://zoklet.net | http://zoklet.net/otg | /derzok/at/gmail/dot/com

Last edited by derzok; 08-04-2008 at 04:19 PM..
derzok is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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 +1. The time now is 07:36 AM.


Advertisement
Log in to turn off these ads.