Online Loans - Personal Loans - Credit Card - Mobile Phones - Mortgage Loans

PDA

View Full Version : ASP Calculations Help


ben.r
Jul 28th 2005, 7:15 am
Hi,

I'm having the simplest of problems we've implemented worldpay and as you might know worldpay doesn't allow you to enter more than one item at a time.

I want to allow the user to enter say quantity 2 and then calculate the value say 15.00 and then add the result into the worldpay code.

I've been trying and I know its simple but cant get my head round it.

Please someone help. This is what I have so far.

<b>Page1</b>

<!-- #include file="includes/boxtop.inc" --><H1>Online Payment<br>
</H1>
<P>Make you online payment below safely using WorldPay.
</P>
<form action="payment1.asp" method="post">
<p>
<script language='javascript'>
function calcNewTotal() {
Amount = 15.00 * parseInt(document.getElementById('Qty').value);
Total = Total + Amount
document.getElementById('Total').value = Total;
}
</script>
<input type="hidden" name="Total" value="">
<input name="Quantity" type="text" id="Qty" value="<%=Quantity%>" onChange="calcNewTotal();">
</p>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
</form>
<p><br>
</p>
<DIV align=left>*</DIV>
<DIV align=left>*
</DIV>
<!-- #include file="includes/boxbottom.inc" -->



<b>Page2</b>

<!-- #include file="includes/boxtop.inc" --><H1>Online Payment<br>
<%dim Total
Total=request.Form("Total")
%>
</H1>
<P>Make you online payment below safely using WorldPay.
</P>
<form action="https://select.worldpay.com/wcc/purchase" method=POST>
<p>
<input type=hidden name="instId" value="">
<input type=hidden name="cartId" value="1">
<input type=hidden name="amount" value="<%=Total%>">
<input type=hidden name="currency" value="GBP">
<input type=hidden name="desc" value="Event Payment">
<input type=hidden name="testMode" value="">
<input type=submit value="Make Payment">
<br>
</p>
</form><br>
<DIV align=left>*</DIV>
<DIV align=left>*
</DIV>
<!-- #include file="includes/boxbottom.inc" -->


Thanks for the help

mopacfan
Jul 28th 2005, 7:45 am
What results are you experiencing currently, or rather, where is it failing?

ben.r
Jul 28th 2005, 7:49 am
the total amout is not being passed to the second page and is not being inserted into the worldpay code. any ideas?

J.D.
Jul 28th 2005, 1:26 pm
<script language='javascript'>
function calcNewTotal() {
Amount = 15.00 * parseInt(document.getElementById('Qty').value);
Total = Total + Amount
document.getElementById('Total').value = Total;
}
</script>
<input type="hidden" name="Total" value="">
<input name="Quantity" type="text" id="Qty" value="<%=Quantity%>" onChange="calcNewTotal();">
</p>
Use IDs with getElementById, not names (e.g. Total). Your Total= line will not work at all - Total is undefined when you are trying to use it (i.e. what's Total in Total+Amount?).

A simple way to see what's going on is to change temporarily the type of the Total input to text instead of hidden. This way you will see the value.

J.D.