Order Form (amount selector)

Discussion in 'JavaScript' started by laLavatrice, Apr 23, 2008.

  1. #1
    Ciao!
    Problem with an order form: I've got a product list which opens a report page with grand total and the choosen articles indeed.
    Have you already heard it? "Confirmable Order Form" in javascript.internet.com
    So far so good.

    I want to add an amount selector input (drop-down menu with 1, 2, 3 etc.) in the main page that also should be modify the results (grand totale) table in the second one...

    Is there anyone who can help me... Italy seems to be unable.

    Thanks


    This is the main page...
    <html>
    <head>
    <title>nn</title>
    </head>

    <body>
    <form name=orderform action="conferma-ordine.htm">
    <table>
    <tr>
    <td><input type=checkbox name=item1A value="L001-titolo1*35.00$"></td>
    <td>titolo1</td>
    </tr>
    <tr>
    <td><input type=checkbox name=item2A value="L002-titolo2*50.00$"></td>
    <td>titolo2</td>
    </tr>
    </table>
    <input type="submit" value="ACQUISTA!"><input type="RESET" value="Cancella">

    </body>

    </html>


    ... and this is the report-page...
    <html>
    <head>
    <title>conferma</title>

    <SCRIPT LANGUAGE="JavaScript">

    <!-- This script and many more are available free online at -->
    <!-- The JavaScript Source!! http://javascript.internet.com -->

    <!-- Begin
    function decodeString() {
    valNum = new Array();
    valData = new Array();
    var string, length, dataCount, orderData, grandTotal;
    string = "" + unescape(location.search);
    string = string.substring(1,string.length);
    length = location.search.length;
    orderData = "";
    dataCount = 1;
    for (var c = 0; c < string.length; c++)
    if (string.charAt(c).indexOf("&") != -1) dataCount++;

    orderData = "<table border=0 width='400px' cellpadding='2px' cellspacing='5px'>";
    orderData += "<tr bgcolor='#CCCCCC'><td><div id='intestazione'>Item</div></td><td><div id='intestazione'>descrizione</div></td><td><div id='intestazione'>spesa</div></td></tr>";
    grandTotal = 0;
    for (var i = 0; i < dataCount; i++)
    {
    valNum = string.substring(0,string.indexOf("="));
    string = string.substring(string.indexOf("=")+1,string.length);
    if (i == dataCount-1) valData = string;
    else valData = string.substring(0,string.indexOf("&"));
    ampd = valData.indexOf("&");
    pipe = valData.indexOf("-");
    star = valData.indexOf("*");
    line = valData.indexOf("$");
    itemnum = string.substring(0,pipe);
    itemdsc = string.substring(pipe+1,star);
    itemcst = string.substring(star+1,line);
    string = string.substring(ampd+1,string.length);

    orderData += "<tr>";
    orderData += "<input type=hidden name=item" + (i+1) + "num value='" + itemnum + "'>";
    orderData += "<input type=hidden name=item" + (i+1) + "dsc value='" + itemdsc + "'>";
    orderData += "<input type=hidden name=item" + (i+1) + "cst value='$" + itemcst + "'>";
    orderData += "<td>" + itemnum + "</td>";
    orderData += "<td>" + itemdsc + "</td>";
    orderData += "<td>" + itemcst + "</td>";
    orderData += "</tr>";
    grandTotal += parseInt(itemcst);
    }
    orderData += "<tr bgcolor='#666666'>";
    orderData += "<td colspan=2><div id='totale'>TOTALE</div></td><td><div id='totale'>" + grandTotal + ".00</div></td>";
    orderData += "</tr>";
    orderData += "<tr>";
    orderData += "<td colspan=3 align=center><input type='submit' value='CONFERMA'><input type='button' value='Annulla' onClick='java-script:history.go(-1);'></td>";
    orderData += "</tr>";
    orderData += "<input type=hidden name=grandtotal value='$" + grandTotal + ".00'>";
    orderData += "</table>";
    document.write(orderData);
    }
    // End -->
    </script>
    </head>

    <body>


    <script language="JavaScript">
    <!-- Begin
    decodeString();
    // End -->
    </script>

    </form>
    </body>
    </html>
     
    laLavatrice, Apr 23, 2008 IP
  2. laLavatrice

    laLavatrice Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Here http://www.grupposanlucaonlus.it/public/book.htm
    you can find the 2 form versions: what I got and what I wish...
    They're working! Therefore if you select one or more articles and push the botton "ACQUISTA" (BUY), you'll get the second page (the confirmation page, conferma-ordine.htm) with the resume table and the choosen articles.

    My goal is: add the quantity selector value to the script (you can see it in the I-wish-table) and automatic update the grand total...

    Sorry... I Know I ask you much... (maybe TOO much)

    However thanks
    Pino
     
    laLavatrice, Apr 24, 2008 IP
  3. laLavatrice

    laLavatrice Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thank you all guys for interesting.


    You can see here the result: http://www.grupposanlucaonlus.it/book.htm


    Feel free to use this script if you want... but don't forget to leave the credits lines inside the code!!

    Share Your Knowledge
     
    laLavatrice, May 16, 2008 IP