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 04-01-2003, 04:46 PM   PM User | #1
sarah
Regular Coder

 
Join Date: Sep 2002
Location: Nottingham, UK
Posts: 110
Thanks: 0
Thanked 0 Times in 0 Posts
sarah is an unknown quantity at this point
variables n dropdown menus

Hi,

I have a dropdown menu which contains certain values (product names). Is it possible to populate my dropdown menu with a variable that has been passed on from another page?

I.e

Page 1.php

Here I have a selection of products, with images and descriptions.
User decides to buy product A, which is red color, made from China, qty is 5, clicks on the link. Code for the link is:

header("Location: /secure/payment.php?product=A&color=".$color."&type=".$type);

on my payment.php page I have dropdown menu which displays the various products. Users can add / subtract upto 5 products per order. I want to be able to display product A in the dropdown menu for products as the first product in the order.

Any ideas how I could do this?

Thanx in advance

Sarah
__________________
You are not a human being having a spiritual experience, your a spiritual
being having a human experience.
sarah is offline   Reply With Quote
Old 04-01-2003, 05:06 PM   PM User | #2
Spookster
Supreme Overlord


 
Spookster's Avatar
 
Join Date: May 2002
Location: Marion, IA USA
Posts: 6,224
Thanks: 4
Thanked 80 Times in 79 Posts
Spookster will become famous soon enough
Now let me get this straight. The items in the dropdown are already pre-existing, however you want the first item in the dropdown to be what the user selected on a previous page?
__________________
Spookster
CodingForums Supreme Overlord
All Hail Spookster
Who gave you that Ugging infraction? Yeah that's right it was me!
Spookster is offline   Reply With Quote
Old 04-01-2003, 06:36 PM   PM User | #3
sarah
Regular Coder

 
Join Date: Sep 2002
Location: Nottingham, UK
Posts: 110
Thanks: 0
Thanked 0 Times in 0 Posts
sarah is an unknown quantity at this point
ok, maybe i didnt explain myself properly - apologies Spookster. The dropdown menu on the payment.php page is already populated with a list of all the products that are on offer.

I.e

<select name="products" onChange="MM_jumpMenu('parent',this,0)">
<option selected>Product A</option>
<option selected>Product B</option>
<option selected>Product C</option>
<option selected>Product D</option>
<option selected>Product E</option>
....
and so on...
</select>

On my products.php page I have all the products with their descriptions, range of colors, pics, etc. These products at the moment are for visuals only, user see's the product they want, they go to the payment page and using the dropdown menu they select the right product.

What I want to do is make the visuals into links, so that when a user clicks on the link (this could be the in the form of the product image, description or text), they are taken to the payment.php page, and the product they have chosen appears in the dropdown menu. All the user has to do is type in the qty (optional, default is 1), and click on place order button.

Is this a better explanation, or have I confused you even more?
__________________
You are not a human being having a spiritual experience, your a spiritual
being having a human experience.
sarah is offline   Reply With Quote
Old 04-01-2003, 06:42 PM   PM User | #4
Spookster
Supreme Overlord


 
Spookster's Avatar
 
Join Date: May 2002
Location: Marion, IA USA
Posts: 6,224
Thanks: 4
Thanked 80 Times in 79 Posts
Spookster will become famous soon enough
Ok it still almost sounds like what I previously thought.

The items in the dropdown are already pre-existing, however you want the item the user selected on a previous page to be the item that is selected by default on the payment page?
__________________
Spookster
CodingForums Supreme Overlord
All Hail Spookster
Who gave you that Ugging infraction? Yeah that's right it was me!
Spookster is offline   Reply With Quote
Old 04-01-2003, 06:48 PM   PM User | #5
sarah
Regular Coder

 
Join Date: Sep 2002
Location: Nottingham, UK
Posts: 110
Thanks: 0
Thanked 0 Times in 0 Posts
sarah is an unknown quantity at this point
yes, thats it. I did think that u understand this, but it confused me instead - lol
__________________
You are not a human being having a spiritual experience, your a spiritual
being having a human experience.
sarah is offline   Reply With Quote
Old 04-01-2003, 06:59 PM   PM User | #6
Spookster
Supreme Overlord


 
Spookster's Avatar
 
Join Date: May 2002
Location: Marion, IA USA
Posts: 6,224
Thanks: 4
Thanked 80 Times in 79 Posts
Spookster will become famous soon enough
Ok then that is easy to do. You can pass it via the URL as you have done:

URL/payment.php?product=yaks


In your payment page you can dynamically write the necessary code to select the appropriate option by default:

PHP Code:

<?php
$product 
$_GET["product"];
?>


<select name="products" onChange="MM_jumpMenu('parent',this,0)"> 
<option <?php if($product "yaks") echo "selected"?> >yaks</option> 
<option <?php if($product "Product B") echo "selected"?>>Product B</option> 
<option <?php if($product "Product C") echo "selected"?>>Product C</option> 
<option <?php if($product "Product D") echo "selected"?>>Product D</option> 
<option <?php if($product "Product E") echo "selected"?>>Product E</option>
__________________
Spookster
CodingForums Supreme Overlord
All Hail Spookster
Who gave you that Ugging infraction? Yeah that's right it was me!
Spookster is offline   Reply With Quote
Old 04-02-2003, 01:45 PM   PM User | #7
sarah
Regular Coder

 
Join Date: Sep 2002
Location: Nottingham, UK
Posts: 110
Thanks: 0
Thanked 0 Times in 0 Posts
sarah is an unknown quantity at this point
Kool

Thanx Spookster!
__________________
You are not a human being having a spiritual experience, your a spiritual
being having a human experience.
sarah 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 04:34 PM.


Advertisement
Log in to turn off these ads.