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 3 of 3
  1. #1
    Regular Coder
    Join Date
    Mar 2006
    Posts
    459
    Thanks
    3
    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
    Location
    Cottage Grove, Minnesota
    Posts
    9,502
    Thanks
    8
    Thanked 1,089 Times in 1,080 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 04:04 AM.

  • #3
    Senior Coder
    Join Date
    Jan 2007
    Posts
    1,648
    Thanks
    1
    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:

    Code:
    rsvp.php?event_id=1234
    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
    •