1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Pre-determined dropdown value on form

Discussion in 'PHP' started by m0z70, Apr 15, 2010.

  1. #1
    Hi. I'm wondering if someone might be able to give me a solution or suggestion for what I'm hoping to do.

    I have a product page with three products, each with an "Enquire Now" button that links to the contact page.

    On the contact page I'd like to have a dropdown list of each product - ie: your enquiry is regarding: 1, 2, 3.

    However, I'd like either 1, 2 or 3 to be pre-selected, dependant on which link they've clicked on the product page. Is it possible to send some extra info when they click?

    Thanks for your help.
     
    m0z70, Apr 15, 2010 IP
  2. lukeg32

    lukeg32 Peon

    Messages:
    645
    Likes Received:
    19
    Best Answers:
    1
    Trophy Points:
    0
    #2
    Keeping it simple, you can have your enquiry link to /yourenquirypage.php?product=1

    In yourenquirypage.php you then simply need to process the select box with the value in $_GET['product']

    Example: You will want to tidy this code up and verify the contents you pass in, etc, but so you get the idea;

    <form action="f.php" method="post">
    
    <select name="enquiry">
    <option value="1" <?php if(isset($_GET['product']) && $_GET['product'] ==1) print "SELECTED";?>>1</option>
    <option value="2" <?php if(isset($_GET['product']) && $_GET['product'] ==2) print "SELECTED";?>>2</option>
    <option value="3" <?php if(isset($_GET['product']) && $_GET['product'] ==3) print "SELECTED";?>>3</option>
    </select>
    
    </form>
    Code (markup):
     
    lukeg32, Apr 15, 2010 IP
    m0z70 likes this.
  3. m0z70

    m0z70 Member

    Messages:
    285
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    28
    #3
    Great, that's exactly what I was after! I was sure that you could get it form appending ?="" but I wasn't sure how. Thanks!
     
    m0z70, Apr 15, 2010 IP