1.

Solve : HTML help, passing a value from an a href to a form?

Answer»

I have a potentially simple question:

I have a list of images, each image is set up like this:

Code: [Select]<a href="www.whatever.com/contactform.html"><img src="image"/></a>
when a user clicks on these images, it will take them to an HTML page with a simple contact form.

Would it be possible to SEND a VALUE through the href tag so that when the user clicks it, that populates the contact form with information. Say for example that the image was a product and I want to pass a product number to the contact form, so when the clicks an item, they are taken to the form with the product number in an input field? Is this possible with just HTML?Not with just HTML.  Since HTML is a Markup Language, you're not going to be doing much programming.  In order to PASS a variable, which is what you want to do, you have to use a programming language.

If your SERVER is equipped with PHP, all you would have to do would be to add "?id=1234567890" to your URLS in the href= and then add

$gets = empty($_GET['id']) ? '' : $_GET['id'];
?>

And then you could use $gets in your code (but it would require more PHP to access the variable).  Note that that's two APOSTROPHE's, not a double quote.

-rock



Discussion

No Comment Found