1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

ASP Calculations Help

Discussion in 'C#' started by ben.r, Jul 28, 2005.

  1. #1
    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" -->
    SEMrush


    <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
     
    ben.r, Jul 28, 2005 IP
    SEMrush
  2. mopacfan

    mopacfan Peon

    Messages:
    3,273
    Likes Received:
    164
    Best Answers:
    0
    Trophy Points:
    0
    #2
    What results are you experiencing currently, or rather, where is it failing?
     
    mopacfan, Jul 28, 2005 IP
  3. ben.r

    ben.r Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    the total amout is not being passed to the second page and is not being inserted into the worldpay code. any ideas?
     
    ben.r, Jul 28, 2005 IP
  4. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    64
    Best Answers:
    0
    Trophy Points:
    0
    #4
    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.
     
    J.D., Jul 28, 2005 IP