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 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Aug 2009
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question PHP drop down list selector

    I have three files:
    MASTER PAGE.html
    Sign up Page.html
    contact.php

    Ok, so I want to have a list of events on a MASTER PAGE

    No matter what event a person clicks on they will be taken to the same "sign up page" with a form on it where they enter info into various fields.

    contact.php takes the form info and emails it to reservations people.

    even though there is only one sign up page is there a way for the event they select to automatically selected from a drop down menu containing every event?

    thanks. i am working on the code now but my PHP only gets me to the working form but not the auto selection.

  • #2
    Super Moderator
    Join Date
    Feb 2009
    Location
    England
    Posts
    539
    Thanks
    8
    Thanked 63 Times in 54 Posts
    You need to maintain a unique event id, and use that as the name for each select option. Then in the sign up page, you do something like:

    PHP Code:
    foreach($events as $event) {
        if (
    $event['id'] == $_GET['eventid']) {
            echo(
    '<option name="'.$event['id'].'" value="'.$event['name'].'" selected="selected" />');
        } else {
            echo(
    '<option name="'.$event['id'].'" value="'.$event['name'].'" />');
        }

    Last edited by Lamped; 10-27-2009 at 03:24 PM.
    lamped.co.uk :: Design, Development & Hosting
    marcgray.co.uk :: Technical blog


  •  

    Posting Permissions

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