Web Analytics Made Easy -
StatCounter Linking javascript calculator to submission form - CodingForum

Announcement

Collapse
No announcement yet.

Linking javascript calculator to submission form

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Linking javascript calculator to submission form

    I am redesigning my webite to sell one book online and have been working on the cost calculators for the four different postal regions (I have a slightly different page for each Zone). It's all looking good! BUT IT WON'T WORK.

    I can't get it to link to my payment processing company .......... they suggested that I modify their examples, but that doesn't work and in any case are really not suitable for the sale of one book.

    I feel I am only a spit away. If I can get the calculator variable recognised by their 'amount'. (I am a novice).

    Thanks,

    Mike


    COST CALCULATOR

    Books and delivery cost calculator - UK
    Enter number of books to order
    Total cost including post & packing



    <html>
    <head>

    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>UK books cost calculator</title>

    <SCRIPT LANGUAGE="JavaScript">
    function formatCurrency(num) {
    num = num.toString().replace(/\£|\,/g,'');
    if(isNaN(num))
    num = "0";
    sign = (num == (num = Math.abs(num)));
    num = Math.floor(num*100+0.50000000001);
    cents = num%100;
    num = Math.floor(num/100).toString();
    if(cents<10)
    cents = "0" + cents;
    for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
    num = num.substring(0,num.length-(4*i+3))+','+
    num.substring(num.length-(4*i+3));
    return (((sign)?'':'-') + num + '.' + cents);
    }
    </script>

    </head>

    <body>
    <h1>Books and delivery cost calculator - UK</h1>
    <form name="metric_form">
    <input type="text" name="book_box" size="8"> Enter number of books to order<br>

    <input type="text" name="cost_box" size="8"> Total cost including post & packing<br><br>

    <input type="button" name="calculate" value="Calculate Cost"
    onClick="var books;
    var books_cost;
    var post;
    books=document.metric_form.book_box.value;
    books_cost=books*9.99;
    post=books*0.60+2.15;
    document.metric_form.cost_box.value=formatCurrency(books_cost+post)"><br><br>
    <input type="button" name="reset" value="Reset form"
    onClick="document.metric_form.book_box.value=''
    document.metric_form.cost_box.value=''">

    </form>

    </body>
    </html>


    WORLDPAY LINK (THAT IT WON'T LINK TO)

    <form action="https://select.worldpay.com/wcc/purchase" method=POST>

    <input type=hidden name="instId" value="1234">

    <input type=hidden name="cartId" value="101KT0098">

    <input type=hidden name="amount" value="25.35"> (The £25.35 is worldpay's example'

    <input type=hidden name="currency" value="GBP">

    <input type=hidden name="desc" value="Blue T-Shirt, Medium">

    <input type=hidden name="testMode" value="100">

    <input type=submit value="Buy This">

    </form>
Working...
X