PDA

View Full Version : Form sent through Hyperlink?


adamci
09-17-2008, 10:35 PM
Hello,

My question seems simple but I'm having a hard time figuring it out. Basically I have shadowbox (like lightbox) installed on my site and it works great with hyperlinks but not so well with form submit buttons. After trying to figure out how get shadowbox to work with forms, with no luck, I'm trying a different option. Hyperlinks. Since shadowbox works so well with links, Is there a way that I can have some hidden form values, along with form drop downs and the like, transfered over to a link that will then launch into shadowbox? I read about javascript being able to do this but can't find any good solutions.

Any help?

BonRouge
09-17-2008, 11:07 PM
I don't know about shadowbox, but you could add variables to a query string of a link, which would pass your form data with the GET method.
You would add onchange events to the input elements to call a function that would change the query string of the link URL whenever something changed.
How does that sound?

adamci
09-18-2008, 08:54 AM
that sounds just right. Now I'm not an expert in codeing, so Ifsomeoe could give me an example of this that would be great.

BonRouge
09-18-2008, 10:45 AM
Something like this would do it:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css">
* {
margin:0;
padding:0;
}
body {
background-color:white;
}
</style>
<script type="text/javascript">
function info() {
var name=document.getElementById('name').value;
var phone=document.getElementById('phone').value;
document.getElementById('theLink').href="nextpage.php?name="+escape(name)+"&phone="+escape(phone);
}
window.onload=function() {
document.getElementById('name').onkeyup=info;
document.getElementById('phone').onkeyup=info;
}
</script>
</head>
<body>
<form action="" method="">
<p><label>Name: <input type="text" id="name" name="name"></label></p>
<p><label>Phone no.: <input type="text" id="phone" name="phone"></label></p>
</form>
<p><a href="" id="theLink">Send the info</a></p>
</body>
</html>


It's not perfect, but it's the basic idea.

I hope that helps.

adamci
09-19-2008, 10:32 PM
Ok so basically I have a shopping cart. I have the option to create an "add to cart" button via hyperlink or form. I HAVE to use form because of the options i'm including which hyperlinks don't support.

Here is an example of my add to cart Form:

<form action="http://ww11.aitsafe.com/cf/add.cfm" method="post">

<input name="userid" type="hidden" value="USERID" />

<input name="product" type="hidden" value="PRODUCT NAME" />

<input name="price" type="hidden" value="PRICE" />
<input name="return"type="hidden"value="www.example.com" />
<input type="hidden" name="hash" value="HASH">
<input type="text" name=qty1 size="3">
<input type="image" src="http://www.example.png" alt="Add to Cart" value="submit">
</form>

Could you help me adapt that type of form into your example code? I have about 25 products, meaning about 25 of these forms with different data in them.

BonRouge
09-20-2008, 03:49 AM
Well, as I said, you would need to be using the GET method for this to work, which you're not. (You're using the POST method).

adamci
09-20-2008, 03:26 PM
Would It matter if I changed it to GET? Or will it not pass my hidden values and such?

BonRouge
09-20-2008, 06:42 PM
You said you're no expert and all that... Do you have control over this page: http://ww11.aitsafe.com/cf/add.cfm ? Are you able to edit that so that it accepts GET data rather than POST data?