...

View Full Version : How to send a JS form total into a hidden input type



chocko638
06-05-2004, 09:00 AM
Hello all, I have a problem. I have a JS order form on my website and I need to send the total to my third party credit card processor. My order form script is as follows;

function CalculateTotals() {
f=document.orderform;
f.ssgt.value=parseInt(f.ssg.value)*25;
f.ssot.value=parseInt(f.sso.value)*25;
f.sswt.value=parseInt(f.ssw.value)*25;
f.lsbt.value=parseInt(f.lsb.value)*30;
f.lswt.value=parseInt(f.lsw.value)*30;
f.tqbwt.value=parseInt(f.tqbw.value)*30;
f.tqbgt.value=parseInt(f.tqbg.value)*30;
f.tqmgt.value=parseInt(f.tqmg.value)*30;
f.tqblwt.value=parseInt(f.tqblw.value)*30;
f.out.value=parseInt(f.ou.value)*25;
f.but.value=parseInt(f.bu.value)*25;
f.gut.value=parseInt(f.gu.value)*25;
f.bgwst.value=parseInt(f.bgws.value)*25;
f.bpwst.value=parseInt(f.bpws.value)*25;
f.bywst.value=parseInt(f.byws.value)*25;
f.grandtotal.value=parseInt(f.ssgt.value)
+parseInt(f.ssot.value)
+parseInt(f.sswt.value)
+parseInt(f.lsbt.value)
+parseInt(f.lswt.value)
+parseInt(f.tqbwt.value)
+parseInt(f.tqbgt.value)
+parseInt(f.tqmgt.value)
+parseInt(f.tqblwt.value)
+parseInt(f.out.value)
+parseInt(f.but.value)
+parseInt(f.gut.value)
+parseInt(f.bgwst.value)
+parseInt(f.bpwst.value)
+parseInt(f.bywst.value)}

The html form code supplied by my credit card processor is as follows;

<form method="POST" action="https://payments.verisign.com.au/payflowlink">
<input type="hidden" name="LOGIN" value="Your LOGIN here">
<input type="hidden" name="PARTNER" value="VSA">
<!-- The transaction AMOUNT must be at least 1.00 -->
<input type="hidden" name="AMOUNT" value="Total transaction AMOUNT here">
<input type="hidden" name="TYPE" value="Valid transaction TYPE here">
<input type="submit" value="Click here to Purchase">
</form>

Their code works OK if you have a submit button for every item you want to sell because you just put individual dollar values into the amount value field. I need to know how I can put the grandtotal value from my order form in there instead.
Any help is much appreciated,
Thanks.

Mr J
06-05-2004, 02:29 PM
Have you tried

f.AMOUNT.value=f.grandtotal.value


I just noticed the form code supplied by your credit card processor does not have a name so give that form a name and go

document.formname.AMOUNT.value=f.grandtotal.value

where formname is the name of the form supplied by your credit cardprocessor

chocko638
06-07-2004, 03:45 AM
Many thanks Mr J, I had a rough idea of what was required but am not familiar enough with the syntax. Followed your advice and it worked just fine but only after I wasted 3 hours and then realised I'd left off 1 set of quotation marks, it's always in the last place you look......
Thanks again.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum