Jump to content
Stef's Coding Community
Sign in to follow this  
joomlavideos

Pre-select PHP form elements based on history

Recommended Posts

Hi,

 

My client would like me to build a simple PHP form for viewers to select items they would like more information on. No problem. They would like the form to be pre-selected with an item they just selected on a previous page.

 

In other words, if they were looking at a vacation page describing a trip to vegas, and they click "buy now", (btw, there will be no shopping cart) or "more info", the subsequent form on the resulting page would have that vacation preselected.

 

This is requested in an effort to keep the clicks to a minimum for the user.

 

Couldn't this be done by attaching an "ID" to the "more info" button on what ever page they came from?

 

Your help is appreciated.

Share this post


Link to post
Share on other sites

Yeah, using an ID is probably the easiest way. Pass the id in the URL

 

yoursite.com/form.php?id=2

 

and then in the form.php page, get the id from the URL using $_GET (make sure it is a valid int, otherwise people could edit the URL to add their own values instead) and use it to select the correct items.

Share this post


Link to post
Share on other sites

Thanks for your replies. I did end up passing an ID via the link and used the $_GET to both, show the "vacation" name visibly on the form, and also to pass the ID through the form data using a hidden input! :clap::)

 

So thanks for your help.

 

P.S.

 

@Ben - your logo is VERY cool!

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...