Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Mar 2006
    Thanked 0 Times in 0 Posts

    Selecting Things Automatically In Form From Previous Page...

    Hi all I have a list of events on my web site, next to each one is an RSVP link... When the user clicks on 1 it takes them to a form to fill out, one of the fields is a drop down of all the events... I thought it would be cool though if the form has automatically selected the event from the user's RSVP click... Can this be handled by PHP or is it JavaScript?

  • #2
    Master Coder
    Join Date
    Jun 2003
    Cottage Grove, Minnesota
    Thanked 1,093 Times in 1,084 Posts
    It could be either, because you can use cookies with both PHP and/or Javascripting.

    The first form would go to a script that sets the cookie(s).
    That script would redirect to the next form ... the user would
    not see the "middle-man" where the cookie gets set because
    it executes and re-directs. Pretty much the same thing as
    a log-in script.

    You could use the cookies to retain all of the 1st form variables.

    Just remember that you can't set a cookie and use it in the same
    script without a refresh in-between. It's that refresh (header) that
    sets the cookie when the page is displayed. That is the purpose
    for that script in-between.


    All that being said (about cookies).... if your first form goes
    directly to the next form, you really don't need to use cookies at all.
    The 2nd form can read variables that get sent from the 1st one.

    A good reason to use cookies: in case they finish the first form and
    don't complete the 2nd form. You can detect that if they return to
    your site and let them know that the form was only 1/2 finished.

    You can also choose to give them the option to "retain their settings"
    or not (by using cookies)... example: "remember me the next time".
    Last edited by mlseim; 02-18-2008 at 05:04 AM.

  • #3
    Senior Coder
    Join Date
    Jan 2007
    Thanked 58 Times in 54 Posts
    I thought it would be cool
    Rather than it being cool, I'd suggest that this is a requirement. If I click on a link to identify what I want to RSVP for, I don't want to have select again what I'm RSVPing for.

    You can do it with just PHP.

    Form your link like this:

    Then in rsvp.php, you'd read $_GET['event_id'] while looping through all the events and compare the ID. If they are equal, echo 'selected="selected"'.


    Posting Permissions

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