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 7 of 7
  1. #1
    Regular Coder
    Join Date
    Sep 2002
    Location
    Nottingham, UK
    Posts
    110
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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.

  • #2
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,278
    Thanks
    4
    Thanked 83 Times in 82 Posts
    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

  • #3
    Regular Coder
    Join Date
    Sep 2002
    Location
    Nottingham, UK
    Posts
    110
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #4
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,278
    Thanks
    4
    Thanked 83 Times in 82 Posts
    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

  • #5
    Regular Coder
    Join Date
    Sep 2002
    Location
    Nottingham, UK
    Posts
    110
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #6
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,278
    Thanks
    4
    Thanked 83 Times in 82 Posts
    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

  • #7
    Regular Coder
    Join Date
    Sep 2002
    Location
    Nottingham, UK
    Posts
    110
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Kool

    Thanx Spookster!
    You are not a human being having a spiritual experience, your a spiritual
    being having a human experience.


  •  

    Posting Permissions

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