Jump to content

Form fields to a cookie


fritz.fx

Recommended Posts

Hi all, I've been stuck on this little problem for a while.

I have a form for recurring payments pointing to Paypal where people can select an amount, an interval (1,2,3, & so on) then a duration (weeks, months, years) then submit it. After all the jazz on Paypals site, they are redirected to a "thankyou page" where I insert the relevant data into a DB.

My problem is, Paypal returns (to the thankyou page) everything except the interval and duration.

How can I get Javascript to save those two on submit so I can use PHP to retrieve them after the Paypal page??

 

<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="business" value="<?php echo $paypal_email; ?>" />
<input type="hidden" name="cmd" value="_xclick-subscriptions"> 
<input type="hidden" name="return" value="http://www.the thankyou page.php" />
<input type="hidden" name="item_name" value="the item name"> 
<input type="hidden" name="currency_code" value="AUD"> 
<br /><input name="custom" type="text" class="donate_box_name" value="<?php echo $username; ?>" size="21" maxlength="40" /><br />
Donation amount<br /> 
<select name="a3" class="donate_box_amount">
                <option>$5.00</option>
                <option>$10.00</option>
                <option>$15.00</option>
                <option>$20.00</option>
                <option>$25.00</option>
                <option>$30.00</option>
                <option>$40.00</option>
                <option>$50.00</option>
                <option>$75.00</option>
                <option>$100.00</option>
                <option>$125.00</option>
                <option>$150.00</option>
                <option>$175.00</option>
</select><br />
Donation duration<br /> 
<select name="Duration"> 
<option value="5">1</option> 
<option value="5">2</option> 
<option value="5">3</option> 
<option value="5">4</option>
<option value="5">5</option> 
<option value="5">6</option>  
</select> <br /> 

<select name="Interval"> 
<option value="W" selected="selected">Weeks</option>
<option value="M">Months</option>
<option value="Y">Years</option>
</select><br /> 
<input type="image" src="btn_donate_LG.gif" name="submit" >
</form

 

I've tried a few things, but none of them are "just right"

(One saves all the form fields to a cookie, bit it exceeds the max cookie length and I don't actually get the info I need.  Another works just fine, but it saves the fields into a seperate cookie for each. (All in one would be better))..

 

Any help would be appreciated. I'm on the home stretch with this project and this problem has slowed me down a fair bit.

Link to comment
Share on other sites

Add an onSubmit event handler to your form that writes those values to the cookie

 

example

 

onload = function(){

var form = document.getElementById('form_id');

form.onSubmit = function(){

//write all of the cookie values in like 'key=value; key=value;'

document.cookie = values;

};

};

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.