SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    May 2010
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Calculate Subtotal

    Recently I've been building a form which allows the users to specify quantity and the items of their choice however for some reason I have been unable to calculate the subtotal automatically with Javascript so I wanted to see if anyone can provide a solution.

    The code is attached as a .txt file due to it's length.

    Thanks very much
    Attached Files Attached Files

  2. #2
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    The code is attached as a .txt file due to it's length.
    I opened it and closed it immediately.

    There is no way anyone is going to look at that gigantic blob of code. Dig out the relevant bits and post them directly here (in [highlight=javascript] ... [/highlight] tags).

  3. #3
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    40,288
    Mentioned
    179 Post(s)
    Tagged
    6 Thread(s)
    I auto formatted it for you to make it easier for others to see - (but I can't help with the solution).
    Code:
    <html>
    <head>
    <link rel="stylesheet" type="text/css" href="http://www.intensivejournal.org/css/root_style.css"/>
    <title>The Progoff Intensive Journal &#174; Program - Books and Audio CDs</title>
    <script language="JavaScript" type="text/javascript">
    function isNumber(q)
    {
    return !isNaN(q);
    }
    function calcOrderTotal()
    {
       var numRows = 10;
       var orderTotal = 0.00;
    
       for(var i = 1; i <= numRows; i++)
       {
          var rowQuantity = document.scriptForm["quantity" + i].value;
          var selectedRowPriceIndex = document.scriptForm["title" + i].selectedIndex;
          if(!isNaN(rowQuantity) && selectedRowPriceIndex !== 0)
          {
             var rowPriceTitleArray = document.scriptForm["title" + i].value.split(";");
             var rowPrice = parseFloat(rowPriceTitleArray[0], 10);
             var rowTotalPrice = rowQuantity * rowPrice;
             orderTotal += rowTotalPrice;
          }
       }
       document.scriptForm["orderTotal"].value = orderTotal.toFixed(2);
    }
        function calcTotal(field) {
            var cells = field.parentNode.parentNode.getElementsByTagName("td");
            // Get Quantity
            _quantity = cells[1].getElementsByTagName("input")[0].value;
            if( _quantity == "" ) _quantity = 0;
            // Get Code and Price Unit
            _item = cells[2].getElementsByTagName("select")[0];
            _itemValueArray = _item.options[_item.selectedIndex].value.split(";");
            _UnitPrice = _itemValueArray[0];
            _Code = _itemValueArray[1];
            // Set selected code, price unit and total of the current row
            cells[3].getElementsByTagName("input")[0].value = _Code;
            cells[4].getElementsByTagName("input")[0].value = _UnitPrice;
            cells[5].getElementsByTagName("input")[0].value = (_quantity * _UnitPrice).toFixed(2);
        }
    </script>
    <base href="http://www.intensivejournal.org/info/buyItems.php">
    </head>
    <body>
    <center>
        <table border="0" cellpadding="0" cellspacing="0">
            <tbody>
                <tr>
                    <td width="740">
                    <table border="0" cellpadding="0" cellspacing="0">
                        <tbody>
                            <tr>
                                <td><a class="logo" href="http://www.intensivejournal.org/index.php"> <img src="http://www.intensivejournal.org/images/header.jpg" border="0" width="740"> </a> </td>
                            </tr>
                            <tr>
                                <td class="topThickLine"></td>
                            </tr>
                            <tr>
                                <td class="topThinLine"></td>
                            </tr>
                        </tbody>
                    </table>
                    <table border="0" cellpadding="0" cellspacing="0" width="740">
                        <tbody>
                            <tr>
                                <td class ="leftPadding">
                                <table  border="0" cellpadding="0" cellspacing="0">
                                    <tr>
                                        <td class = "leftNavTitle"><a href="http://www.intensivejournal.org/">Home</a><br>
                                            <br>
                                            About Us </td>
                                    </tr>
                                    <tr>
                                        <td class = "leftNavText"><ul>
                                                <li><a class = "leftNavLink" href="http://www.intensivejournal.org/about/aboutProgoff.php">The Founder: Ira Progoff</a><br>
                                                <li><a class = "leftNavLink" href="http://www.intensivejournal.org/about/aboutDialogue.php">About Dialogue House</a><br>
                                                <li><a class = "leftNavLink" href="http://www.intensivejournal.org/about/aboutRecent.php"> Recent Developments</a><br>
                                            </ul>
                                            <br>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class = "leftNavTitle"> About the Method</td>
                                    </tr>
                                    <tr>
                                        <td class = "leftNavText"><ul>
                                                <li><a class = "leftNavLink" href="http://www.intensivejournal.org/about/aboutMethod.php">Overview</a><br>
                                                <li><a class = "leftNavLink" href="http://www.intensivejournal.org/about/aboutWorkbook.php">Intensive Journal Workbook</a>
                                                <li><a class = "leftNavLink" href="http://www.intensivejournal.org/about/aboutFeedback.php">Journal Feedback Process</a><br>
                                                <li><a class = "leftNavLink" href="http://www.intensivejournal.org/about/aboutFeatures.php">Features and Principles</a><br>
                                                <li><a class = "leftNavLink" href="http://www.intensivejournal.org/about/aboutDreams.php">Dreams and Imagery</a><br>
                                                <li><a class = "leftNavLink" href="http://www.intensivejournal.org/about/aboutMeditation.php">Entrance Meditation</a><br>
                                                    <br>
                                            </ul></td>
                                    </tr>
                                    <tr>
                                        <td class = "leftNavTitle"> General Workshops </td>
                                    </tr>
                                    <tr>
                                        <td class = "leftNavText"><ul>
                                                <li><a class = "leftNavLink" href="http://www.intensivejournal.org/general/aboutWorkshops.php">About the Workshops</a><br>
                                                <li><a class = "leftNavLink" href="http://www.intensivejournal.org/general/schedules.php">Schedules and Locations</a><br>
                                                <li><a class = "leftNavLink" href="http://www.intensivejournal.org/general/startOne.php">Start a Workshop</a><br>
                                                    <br>
                                            </ul></td>
                                    </tr>
                                    <tr>
                                        <td class = "leftNavTitle"> Specialized Audiences<br>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class = "leftNavText"><ul>
                                                <li><a class = "leftNavLink" href="http://www.intensivejournal.org/specialized/wellness.php">Wellness</a><br>
                                                <li><a class = "leftNavLink" href="http://www.intensivejournal.org/specialized/ministry.php">Ministry</a><br>
                                                <li><a class = "leftNavLink" href="http://www.intensivejournal.org/specialized/criminaljustice.php">Criminal Justice</a>
                                                <li><a class = "leftNavLink" href="http://www.intensivejournal.org/specialized/jobTraining.php">Job Training</a><br>
                                                <li><a class = "leftNavLink" href="http://www.intensivejournal.org/specialized/writers.php">Writers</a><br>
                                                    <br>
                                            </ul></td>
                                    </tr>
                                    <tr>
                                        <td class = "leftNavTitle"> Information <br>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class = "leftNavText"><ul>
                                                <li><a class = "leftNavLink" href="http://www.intensivejournal.org/info/contEd.php">Continuing Education</a><br>
                                                <li> <a class="leftNavLink" href="http://www.intensivejournal.org/info/articles.php">Articles</a><br>
                                                <li> <a class="leftNavLink" href="http://www.intensivejournal.org/info/lifeHistories.php">Life Histories</a>
                                                <li> <a class="leftNavLink" href="http://www.intensivejournal.org/info/newsletter.php">Newsletters</a><br>
                                                <li><a class = "leftNavLink" href="http://www.intensivejournal.org/info/booksAndTapes.php">Books and Audio</a><br>
                                                <li><a class = "leftNavLink" href="http://www.intensivejournal.org/info/become_leader.php">Become a Leader</a><br>
                                                    <br>
                                            </ul></td>
                                    </tr>
                                    <tr>
                                        <td class = "leftNavTitle"> Miscellaneous<br>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class = "leftNavText"><ul>
                                                <li> <a class="leftNavLink" href="http://www.intensivejournal.org/misc/contact.php">Contact Us</a><br>
                                                <li> <a class="leftNavLink" href="http://www.intensivejournal.org/misc/support.php">Support the Program</a><br>
                                                <li> <a class="leftNavLink" href="http://www.intensivejournal.org/misc/refer.php">Refer Your Friends</a><br>
                                                <li><a class="leftNavLink" href="http://www.intensivejournal.org/misc/endorsements.php">Endorse the Method</a><br>
                                                <li><a class = "leftNavLink" href="http://www.intensivejournal.org/misc/join.php">Join Mailing List</a><br>
                                                <li><a class = "leftNavLink" href="http://www.intensivejournal.org/misc/links.php">Links</a><br>
                                                <li><a class = "leftNavLink" href="http://www.intensivejournal.org/misc/sitemap.php">Sitemap</a><br>
                                            </ul></td>
                                    </tr>
                                    </td>
                                    
                                </table>
                        </td>
                        
                        <td class="genericText" width="740"><span class="largeTitle">Order Form</span> | <a class="topNavLink" href="booksAndTapes.php">Back to Books and Audio CDs</a> <br>
                                <br>
                                <strong>Currently this form is under construction. To Place an order, please call </strong> <b>800-221-5844</b><strong> or 631-471-0542</strong>
                                <table class="generic" border="0" cellpadding="0" cellspacing="0">
                                    <tbody>
                                        <tr>
                                            <td class="titleBoxTitle">#</td>
                                            <td class="titleBoxTitle">Quantity</td>
                                            <td class="titleBoxTitle">Title</td>
                                            <td class="titleBoxTitle">Code</td>
                                            <td class="titleBoxTitle">Unit Price</td>
                                            <td class="titleBoxTitle">Total Cost</td>
                                        </tr>
                                    <form name="scriptForm" action="handleBuyItems.php" method="post">
                                    
                                    <tr>
                                        <td class="generic">1.</td>
                                        <td class="generic"><input name="quantity1" size="2" value="1" onChange="calcTotal(this)" type="text"></td>
                                        <td class="generic"><select name="title1" onChange="calcTotal(this)">
                                                <option selected="selected">Select Item Title - Price </option>
                                                <option value="18.95;B-101">Book : At a Journal Workshop - $18.95 </option>
                                                <option value="18.95; B-102">Book : Life Study: Experiencing Creative Lives - $18.95 </option>
                                                <option value="195; A-401">Audio : All Audio CDs - $195 </option>
                                                <option value="15; A-101">Audio : The Well and the Cathedral (Audio) - $15 </option>
                                                <!--<option>Audio : The Star/Cross (Book)
    </option>-->
                                                <option value="15; A-102">Audio : The Star/Cross (Audio) - $15 </option>
                                                <!--<option>Audio : The White Robed Monk (Book)
    </option>-->
                                                <option value="15; A-103">Audio : The White Robed Monk (Audio) - $15 </option>
                                                <option value="40; A-104">Audio : Entrance Meditation™ Series (Audio) - $40 </option>
                                                <option value="15; A-201">Lecture : The Dialogue House Experience - $15 </option>
                                                <option value="15; A-202">Lecture : Non-Analytical Ways of Growth - $15 </option>
                                                <option value="15; A-203">Lecture : Creativity and Spirit in History and Today - $15 </option>
                                                <option value="15; A-202">Lecture : Active Methods of Spiritual Growth - $15 </option>
                                                <option value="15; A-205">Lecture : Walking Dream and Living Myth - $15 </option>
                                                <option value="15; A-206">Lecture : Moving Through Transitions - $15 </option>
                                                <option value="15;    A-207">Lecture : Finding Your Identity - $15 </option>
                                                <option value="15; A-208">Lecture : The Inner Development Process - $15 </option>
                                                <option value="15; A-209">Lecture : The Evolution of Self - $15 </option>
                                                <option value="15; A-210">Lecture : C.G. Jung and the Future - $15 </option>
                                                <option value="15; A-301">Interview : The Dialogue Concept - $15 </option>
                                                <option value="15; A-302">Interview : Beyond Psychotherapy - $15 </option>
                                                <option value="25; A-310">Interview : Both Interviews with Ira Progoff, PhD - A-310 - $25 </option>
                                                <!--<option>Book : The Symbolic and the Real (1963)
    </option><option>Book : Depth Psychology and the Modern Man (1959)
    </option><option>Book : The Dynamics of Hope (1985)
    </option><option>Book : The Death and Rebirth of Depth Psychology (1956)
    </option><option>Book : Jung's Psychology and Its Social Meaning (1953)
    </option><option>Book : Jung, Synchronicity and Human Destiny (1973)
    </option><option>Book : The Cloud of Unknowing (1957)
    </option><option>Book : The Image of an Oracle (1964)
    </option>-->
                                                <!--<option>Audio : The Well and the Cathedral (Book)
    </option>-->
                                            </select></td>
                                        <td class="generic"><input name="itemNo100" size="5" type="text"></td>
                                        <td class="generic"><input name="unitPrice100" size="5"  readonly="readonly" type="text"></td>
                                        <td class="generic"><input name="totalCost100" size="5" value="0.00" type="text"></td>
                                    </tr>
                                    <tr>
                                        <td class="generic">2.</td>
                                        <td class="generic"><input name="quantity2" value="1" size="2" onChange="calcTotal(this)" type="text"></td>
                                        <td class="generic"><select name="title2" onChange="calcTotal(this)">
                                                <option selected="selected">Select Item Title - Price </option>
                                                <option value="18.95;B-101">Book : At a Journal Workshop - $18.95 </option>
                                                <option value="18.95; B-102">Book : Life Study: Experiencing Creative Lives - $18.95 </option>
                                                <option value="195; A-401">Audio : All Audio CDs - $195 </option>
                                                <option value="15; A-101">Audio : The Well and the Cathedral (Audio) - $15 </option>
                                                <!--<option>Audio : The Star/Cross (Book)
    </option>-->
                                                <option value="15; A-102">Audio : The Star/Cross (Audio) - $15 </option>
                                                <!--<option>Audio : The White Robed Monk (Book)
    </option>-->
                                                <option value="15; A-103">Audio : The White Robed Monk (Audio) - $15 </option>
                                                <option value="40; A-104">Audio : Entrance Meditation™ Series (Audio) - $40 </option>
                                                <option value="15; A-201">Lecture : The Dialogue House Experience - $15 </option>
                                                <option value="15; A-202">Lecture : Non-Analytical Ways of Growth - $15 </option>
                                                <option value="15; A-203">Lecture : Creativity and Spirit in History and Today - $15 </option>
                                                <option value="15; A-202">Lecture : Active Methods of Spiritual Growth - $15 </option>
                                                <option value="15; A-205">Lecture : Walking Dream and Living Myth - $15 </option>
                                                <option value="15; A-206">Lecture : Moving Through Transitions - $15 </option>
                                                <option value="15;    A-207">Lecture : Finding Your Identity - $15 </option>
                                                <option value="15; A-208">Lecture : The Inner Development Process - $15 </option>
                                                <option value="15; A-209">Lecture : The Evolution of Self - $15 </option>
                                                <option value="15; A-210">Lecture : C.G. Jung and the Future - $15 </option>
                                                <option value="15; A-301">Interview : The Dialogue Concept - $15 </option>
                                                <option value="15; A-302">Interview : Beyond Psychotherapy - $15 </option>
                                                <option value="25; A-310">Interview : Both Interviews with Ira Progoff, PhD - A-310 - $25 </option>
                                                <!--<option>Book : The Symbolic and the Real (1963)
    </option><option>Book : Depth Psychology and the Modern Man (1959)
    </option><option>Book : The Dynamics of Hope (1985)
    </option><option>Book : The Death and Rebirth of Depth Psychology (1956)
    </option><option>Book : Jung's Psychology and Its Social Meaning (1953)
    </option><option>Book : Jung, Synchronicity and Human Destiny (1973)
    </option><option>Book : The Cloud of Unknowing (1957)
    </option><option>Book : The Image of an Oracle (1964)
    </option>-->
                                                <!--<option>Audio : The Well and the Cathedral (Book)
    </option>-->
                                            </select></td>
                                        <td class="generic"><input name="itemNo2" size="5" type="text"></td>
                                        <td class="generic"><input name="unitPrice2" size="5"  readonly="readonly" type="text"></td>
                                        <td class="generic"><input name="totalCost2" size="5" value="0.00" type="text"></td>
                                    </tr>
                                    <tr>
                                        <td class="generic">3.</td>
                                        <td class="generic"><input name="quantity3" value="1" size="2" onChange="calcTotal(this)" type="text"></td>
                                        <td class="generic"><select name="title3" onChange="calcTotal(this)">
                                                <option selected="selected">Select Item Title - Price </option>
                                                <option value="18.95;B-101">Book : At a Journal Workshop - $18.95 </option>
                                                <option value="18.95; B-102">Book : Life Study: Experiencing Creative Lives - $18.95 </option>
                                                <option value="195; A-401">Audio : All Audio CDs - $195 </option>
                                                <option value="15; A-101">Audio : The Well and the Cathedral (Audio) - $15 </option>
                                                <!--<option>Audio : The Star/Cross (Book)
    </option>-->
                                                <option value="15; A-102">Audio : The Star/Cross (Audio) - $15 </option>
                                                <!--<option>Audio : The White Robed Monk (Book)
    </option>-->
                                                <option value="15; A-103">Audio : The White Robed Monk (Audio) - $15 </option>
                                                <option value="40; A-104">Audio : Entrance Meditation™ Series (Audio) - $40 </option>
                                                <option value="15; A-201">Lecture : The Dialogue House Experience - $15 </option>
                                                <option value="15; A-202">Lecture : Non-Analytical Ways of Growth - $15 </option>
                                                <option value="15; A-203">Lecture : Creativity and Spirit in History and Today - $15 </option>
                                                <option value="15; A-202">Lecture : Active Methods of Spiritual Growth - $15 </option>
                                                <option value="15; A-205">Lecture : Walking Dream and Living Myth - $15 </option>
                                                <option value="15; A-206">Lecture : Moving Through Transitions - $15 </option>
                                                <option value="15;    A-207">Lecture : Finding Your Identity - $15 </option>
                                                <option value="15; A-208">Lecture : The Inner Development Process - $15 </option>
                                                <option value="15; A-209">Lecture : The Evolution of Self - $15 </option>
                                                <option value="15; A-210">Lecture : C.G. Jung and the Future - $15 </option>
                                                <option value="15; A-301">Interview : The Dialogue Concept - $15 </option>
                                                <option value="15; A-302">Interview : Beyond Psychotherapy - $15 </option>
                                                <option value="25; A-310">Interview : Both Interviews with Ira Progoff, PhD - A-310 - $25 </option>
                                                <!--<option>Book : The Symbolic and the Real (1963)
    </option><option>Book : Depth Psychology and the Modern Man (1959)
    </option><option>Book : The Dynamics of Hope (1985)
    </option><option>Book : The Death and Rebirth of Depth Psychology (1956)
    </option><option>Book : Jung's Psychology and Its Social Meaning (1953)
    </option><option>Book : Jung, Synchronicity and Human Destiny (1973)
    </option><option>Book : The Cloud of Unknowing (1957)
    </option><option>Book : The Image of an Oracle (1964)
    </option>-->
                                                <!--<option>Audio : The Well and the Cathedral (Book)
    </option>-->
                                            </select></td>
                                        <td class="generic"><input name="itemNo3" size="5" type="text"></td>
                                        <td class="generic"><input name="unitPrice3" size="5"  readonly="readonly" type="text"></td>
                                        <td class="generic"><input name="totalCost3" size="5" value="0.00" type="text"></td>
                                    </tr>
                                    <tr>
                                        <td class="generic">4.</td>
                                        <td class="generic"><input name="quantity4" value="1" size="2" onChange="calcTotal(this)" type="text"></td>
                                        <td class="generic"><select name="title4" onChange="calcTotal(this)">
                                                <option selected="selected">Select Item Title - Price </option>
                                                <option value="18.95;B-101">Book : At a Journal Workshop - $18.95 </option>
                                                <option value="18.95; B-102">Book : Life Study: Experiencing Creative Lives - $18.95 </option>
                                                <option value="195; A-401">Audio : All Audio CDs - $195 </option>
                                                <option value="15; A-101">Audio : The Well and the Cathedral (Audio) - $15 </option>
                                                <!--<option>Audio : The Star/Cross (Book)
    </option>-->
                                                <option value="15; A-102">Audio : The Star/Cross (Audio) - $15 </option>
                                                <!--<option>Audio : The White Robed Monk (Book)
    </option>-->
                                                <option value="15; A-103">Audio : The White Robed Monk (Audio) - $15 </option>
                                                <option value="40; A-104">Audio : Entrance Meditation™ Series (Audio) - $40 </option>
                                                <option value="15; A-201">Lecture : The Dialogue House Experience - $15 </option>
                                                <option value="15; A-202">Lecture : Non-Analytical Ways of Growth - $15 </option>
                                                <option value="15; A-203">Lecture : Creativity and Spirit in History and Today - $15 </option>
                                                <option value="15; A-202">Lecture : Active Methods of Spiritual Growth - $15 </option>
                                                <option value="15; A-205">Lecture : Walking Dream and Living Myth - $15 </option>
                                                <option value="15; A-206">Lecture : Moving Through Transitions - $15 </option>
                                                <option value="15;    A-207">Lecture : Finding Your Identity - $15 </option>
                                                <option value="15; A-208">Lecture : The Inner Development Process - $15 </option>
                                                <option value="15; A-209">Lecture : The Evolution of Self - $15 </option>
                                                <option value="15; A-210">Lecture : C.G. Jung and the Future - $15 </option>
                                                <option value="15; A-301">Interview : The Dialogue Concept - $15 </option>
                                                <option value="15; A-302">Interview : Beyond Psychotherapy - $15 </option>
                                                <option value="25; A-310">Interview : Both Interviews with Ira Progoff, PhD - A-310 - $25 </option>
                                                <!--<option>Book : The Symbolic and the Real (1963)
    </option><option>Book : Depth Psychology and the Modern Man (1959)
    </option><option>Book : The Dynamics of Hope (1985)
    </option><option>Book : The Death and Rebirth of Depth Psychology (1956)
    </option><option>Book : Jung's Psychology and Its Social Meaning (1953)
    </option><option>Book : Jung, Synchronicity and Human Destiny (1973)
    </option><option>Book : The Cloud of Unknowing (1957)
    </option><option>Book : The Image of an Oracle (1964)
    </option>-->
                                                <!--<option>Audio : The Well and the Cathedral (Book)
    </option>-->
                                            </select></td>
                                        <td class="generic"><input name="itemNo4" size="5" type="text"></td>
                                        <td class="generic"><input name="unitPrice4" size="5"  readonly="readonly" type="text"></td>
                                        <td class="generic"><input name="totalCost4" size="5" value="0.00" type="text"></td>
                                    </tr>
                                    <tr>
                                        <td class="generic">5.</td>
                                        <td class="generic"><input name="quantity5" value="1" size="2" onChange="calcTotal(this)" type="text"></td>
                                        <td class="generic"><select name="title5" onChange="calcTotal(this)">
                                                <option selected="selected">Select Item Title - Price </option>
                                                <option value="18.95;B-101">Book : At a Journal Workshop - $18.95 </option>
                                                <option value="18.95; B-102">Book : Life Study: Experiencing Creative Lives - $18.95 </option>
                                                <option value="195; A-401">Audio : All Audio CDs - $195 </option>
                                                <option value="15; A-101">Audio : The Well and the Cathedral (Audio) - $15 </option>
                                                <!--<option>Audio : The Star/Cross (Book)
    </option>-->
                                                <option value="15; A-102">Audio : The Star/Cross (Audio) - $15 </option>
                                                <!--<option>Audio : The White Robed Monk (Book)
    </option>-->
                                                <option value="15; A-103">Audio : The White Robed Monk (Audio) - $15 </option>
                                                <option value="40; A-104">Audio : Entrance Meditation™ Series (Audio) - $40 </option>
                                                <option value="15; A-201">Lecture : The Dialogue House Experience - $15 </option>
                                                <option value="15; A-202">Lecture : Non-Analytical Ways of Growth - $15 </option>
                                                <option value="15; A-203">Lecture : Creativity and Spirit in History and Today - $15 </option>
                                                <option value="15; A-202">Lecture : Active Methods of Spiritual Growth - $15 </option>
                                                <option value="15; A-205">Lecture : Walking Dream and Living Myth - $15 </option>
                                                <option value="15; A-206">Lecture : Moving Through Transitions - $15 </option>
                                                <option value="15;    A-207">Lecture : Finding Your Identity - $15 </option>
                                                <option value="15; A-208">Lecture : The Inner Development Process - $15 </option>
                                                <option value="15; A-209">Lecture : The Evolution of Self - $15 </option>
                                                <option value="15; A-210">Lecture : C.G. Jung and the Future - $15 </option>
                                                <option value="15; A-301">Interview : The Dialogue Concept - $15 </option>
                                                <option value="15; A-302">Interview : Beyond Psychotherapy - $15 </option>
                                                <option value="25; A-310">Interview : Both Interviews with Ira Progoff, PhD - A-310 - $25 </option>
                                                <!--<option>Book : The Symbolic and the Real (1963)
    </option><option>Book : Depth Psychology and the Modern Man (1959)
    </option><option>Book : The Dynamics of Hope (1985)
    </option><option>Book : The Death and Rebirth of Depth Psychology (1956)
    </option><option>Book : Jung's Psychology and Its Social Meaning (1953)
    </option><option>Book : Jung, Synchronicity and Human Destiny (1973)
    </option><option>Book : The Cloud of Unknowing (1957)
    </option><option>Book : The Image of an Oracle (1964)
    </option>-->
                                                <!--<option>Audio : The Well and the Cathedral (Book)
    </option>-->
                                            </select></td>
                                        <td class="generic"><input name="itemNo5" size="5" type="text"></td>
                                        <td class="generic"><input name="unitPrice5" size="5"  readonly="readonly" type="text"></td>
                                        <td class="generic"><input name="totalCost5" size="5" value="0.00" type="text"></td>
                                    </tr>
                                    <tr>
                                        <td class="generic">6.</td>
                                        <td class="generic"><input name="quantity6" size="2" value="1" onChange="calcTotal(this)" type="text"></td>
                                        <td class="generic"><select name="title6" onChange="calcTotal(this)">
                                                <option selected="selected">Select Item Title - Price </option>
                                                <option value="18.95;B-101">Book : At a Journal Workshop - $18.95 </option>
                                                <option value="18.95; B-102">Book : Life Study: Experiencing Creative Lives - $18.95 </option>
                                                <option value="195; A-401">Audio : All Audio CDs - $195 </option>
                                                <option value="15; A-101">Audio : The Well and the Cathedral (Audio) - $15 </option>
                                                <!--<option>Audio : The Star/Cross (Book)
    </option>-->
                                                <option value="15; A-102">Audio : The Star/Cross (Audio) - $15 </option>
                                                <!--<option>Audio : The White Robed Monk (Book)
    </option>-->
                                                <option value="15; A-103">Audio : The White Robed Monk (Audio) - $15 </option>
                                                <option value="40; A-104">Audio : Entrance Meditation™ Series (Audio) - $40 </option>
                                                <option value="15; A-201">Lecture : The Dialogue House Experience - $15 </option>
                                                <option value="15; A-202">Lecture : Non-Analytical Ways of Growth - $15 </option>
                                                <option value="15; A-203">Lecture : Creativity and Spirit in History and Today - $15 </option>
                                                <option value="15; A-202">Lecture : Active Methods of Spiritual Growth - $15 </option>
                                                <option value="15; A-205">Lecture : Walking Dream and Living Myth - $15 </option>
                                                <option value="15; A-206">Lecture : Moving Through Transitions - $15 </option>
                                                <option value="15;    A-207">Lecture : Finding Your Identity - $15 </option>
                                                <option value="15; A-208">Lecture : The Inner Development Process - $15 </option>
                                                <option value="15; A-209">Lecture : The Evolution of Self - $15 </option>
                                                <option value="15; A-210">Lecture : C.G. Jung and the Future - $15 </option>
                                                <option value="15; A-301">Interview : The Dialogue Concept - $15 </option>
                                                <option value="15; A-302">Interview : Beyond Psychotherapy - $15 </option>
                                                <option value="25; A-310">Interview : Both Interviews with Ira Progoff, PhD - A-310 - $25 </option>
                                                <!--<option>Book : The Symbolic and the Real (1963)
    </option><option>Book : Depth Psychology and the Modern Man (1959)
    </option><option>Book : The Dynamics of Hope (1985)
    </option><option>Book : The Death and Rebirth of Depth Psychology (1956)
    </option><option>Book : Jung's Psychology and Its Social Meaning (1953)
    </option><option>Book : Jung, Synchronicity and Human Destiny (1973)
    </option><option>Book : The Cloud of Unknowing (1957)
    </option><option>Book : The Image of an Oracle (1964)
    </option>-->
                                                <!--<option>Audio : The Well and the Cathedral (Book)
    </option>-->
                                            </select></td>
                                        <td class="generic"><input name="itemNo6" size="5" type="text"></td>
                                        <td class="generic"><input name="unitPrice6" size="5"  readonly="readonly" type="text"></td>
                                        <td class="generic"><input name="totalCost6" size="5" value="0.00" type="text"></td>
                                    </tr>
                                    <tr>
                                    <tr>
                                        <td class="generic">7.</td>
                                        <td class="generic"><input name="quantity7" value="1" size="2" onChange="calcTotal(this)" type="text"></td>
                                        <td class="generic"><select name="title7" onChange="calcTotal(this)">
                                                <option selected="selected">Select Item Title - Price </option>
                                                <option value="18.95;B-101">Book : At a Journal Workshop - $18.95 </option>
                                                <option value="18.95; B-102">Book : Life Study: Experiencing Creative Lives - $18.95 </option>
                                                <option value="195; A-401">Audio : All Audio CDs - $195 </option>
                                                <option value="15; A-101">Audio : The Well and the Cathedral (Audio) - $15 </option>
                                                <!--<option>Audio : The Star/Cross (Book)
    </option>-->
                                                <option value="15; A-102">Audio : The Star/Cross (Audio) - $15 </option>
                                                <!--<option>Audio : The White Robed Monk (Book)
    </option>-->
                                                <option value="15; A-103">Audio : The White Robed Monk (Audio) - $15 </option>
                                                <option value="40; A-104">Audio : Entrance Meditation™ Series (Audio) - $40 </option>
                                                <option value="15; A-201">Lecture : The Dialogue House Experience - $15 </option>
                                                <option value="15; A-202">Lecture : Non-Analytical Ways of Growth - $15 </option>
                                                <option value="15; A-203">Lecture : Creativity and Spirit in History and Today - $15 </option>
                                                <option value="15; A-202">Lecture : Active Methods of Spiritual Growth - $15 </option>
                                                <option value="15; A-205">Lecture : Walking Dream and Living Myth - $15 </option>
                                                <option value="15; A-206">Lecture : Moving Through Transitions - $15 </option>
                                                <option value="15;    A-207">Lecture : Finding Your Identity - $15 </option>
                                                <option value="15; A-208">Lecture : The Inner Development Process - $15 </option>
                                                <option value="15; A-209">Lecture : The Evolution of Self - $15 </option>
                                                <option value="15; A-210">Lecture : C.G. Jung and the Future - $15 </option>
                                                <option value="15; A-301">Interview : The Dialogue Concept - $15 </option>
                                                <option value="15; A-302">Interview : Beyond Psychotherapy - $15 </option>
                                                <option value="25; A-310">Interview : Both Interviews with Ira Progoff, PhD - A-310 - $25 </option>
                                                <!--<option>Book : The Symbolic and the Real (1963)
    </option><option>Book : Depth Psychology and the Modern Man (1959)
    </option><option>Book : The Dynamics of Hope (1985)
    </option><option>Book : The Death and Rebirth of Depth Psychology (1956)
    </option><option>Book : Jung's Psychology and Its Social Meaning (1953)
    </option><option>Book : Jung, Synchronicity and Human Destiny (1973)
    </option><option>Book : The Cloud of Unknowing (1957)
    </option><option>Book : The Image of an Oracle (1964)
    </option>-->
                                                <!--<option>Audio : The Well and the Cathedral (Book)
    </option>-->
                                            </select></td>
                                        <td class="generic"><input name="itemNo7" size="5" type="text"></td>
                                        <td class="generic"><input name="unitPrice7" size="5"  readonly="readonly" type="text"></td>
                                        <td class="generic"><input name="totalCost7" size="5" value="0.00" type="text"></td>
                                    </tr>
                                    <tr>
                                        <td class="generic">8.</td>
                                        <td class="generic"><input name="quantity8" value="1" size="2" onChange="calcTotal(this)" type="text"></td>
                                        <td class="generic"><select name="title8" onChange="calcTotal(this)">
                                                <option selected="selected">Select Item Title - Price </option>
                                                <option value="18.95;B-101">Book : At a Journal Workshop - $18.95 </option>
                                                <option value="18.95; B-102">Book : Life Study: Experiencing Creative Lives - $18.95 </option>
                                                <option value="195; A-401">Audio : All Audio CDs - $195 </option>
                                                <option value="15; A-101">Audio : The Well and the Cathedral (Audio) - $15 </option>
                                                <!--<option>Audio : The Star/Cross (Book)
    </option>-->
                                                <option value="15; A-102">Audio : The Star/Cross (Audio) - $15 </option>
                                                <!--<option>Audio : The White Robed Monk (Book)
    </option>-->
                                                <option value="15; A-103">Audio : The White Robed Monk (Audio) - $15 </option>
                                                <option value="40; A-104">Audio : Entrance Meditation™ Series (Audio) - $40 </option>
                                                <option value="15; A-201">Lecture : The Dialogue House Experience - $15 </option>
                                                <option value="15; A-202">Lecture : Non-Analytical Ways of Growth - $15 </option>
                                                <option value="15; A-203">Lecture : Creativity and Spirit in History and Today - $15 </option>
                                                <option value="15; A-202">Lecture : Active Methods of Spiritual Growth - $15 </option>
                                                <option value="15; A-205">Lecture : Walking Dream and Living Myth - $15 </option>
                                                <option value="15; A-206">Lecture : Moving Through Transitions - $15 </option>
                                                <option value="15;    A-207">Lecture : Finding Your Identity - $15 </option>
                                                <option value="15; A-208">Lecture : The Inner Development Process - $15 </option>
                                                <option value="15; A-209">Lecture : The Evolution of Self - $15 </option>
                                                <option value="15; A-210">Lecture : C.G. Jung and the Future - $15 </option>
                                                <option value="15; A-301">Interview : The Dialogue Concept - $15 </option>
                                                <option value="15; A-302">Interview : Beyond Psychotherapy - $15 </option>
                                                <option value="25; A-310">Interview : Both Interviews with Ira Progoff, PhD - A-310 - $25 </option>
                                                <!--<option>Book : The Symbolic and the Real (1963)
    </option><option>Book : Depth Psychology and the Modern Man (1959)
    </option><option>Book : The Dynamics of Hope (1985)
    </option><option>Book : The Death and Rebirth of Depth Psychology (1956)
    </option><option>Book : Jung's Psychology and Its Social Meaning (1953)
    </option><option>Book : Jung, Synchronicity and Human Destiny (1973)
    </option><option>Book : The Cloud of Unknowing (1957)
    </option><option>Book : The Image of an Oracle (1964)
    </option>-->
                                                <!--<option>Audio : The Well and the Cathedral (Book)
    </option>-->
                                            </select></td>
                                        <td class="generic"><input name="itemNo8" size="5" type="text"></td>
                                        <td class="generic"><input name="unitPrice8" size="5"  readonly="readonly" type="text"></td>
                                        <td class="generic"><input name="totalCost8" size="5" value="0.00" type="text"></td>
                                    </tr>
                                    <tr>
                                        <td class="generic">9.</td>
                                        <td class="generic"><input name="quantity9" value="1" size="2" onChange="calcTotal(this)" type="text"></td>
                                        <td class="generic"><select name="title9" onChange="calcTotal(this)">
                                                <option selected="selected">Select Item Title - Price </option>
                                                <option value="18.95;B-101">Book : At a Journal Workshop - $18.95 </option>
                                                <option value="18.95; B-102">Book : Life Study: Experiencing Creative Lives - $18.95 </option>
                                                <option value="195; A-401">Audio : All Audio CDs - $195 </option>
                                                <option value="15; A-101">Audio : The Well and the Cathedral (Audio) - $15 </option>
                                                <!--<option>Audio : The Star/Cross (Book)
    </option>-->
                                                <option value="15; A-102">Audio : The Star/Cross (Audio) - $15 </option>
                                                <!--<option>Audio : The White Robed Monk (Book)
    </option>-->
                                                <option value="15; A-103">Audio : The White Robed Monk (Audio) - $15 </option>
                                                <option value="40; A-104">Audio : Entrance Meditation™ Series (Audio) - $40 </option>
                                                <option value="15; A-201">Lecture : The Dialogue House Experience - $15 </option>
                                                <option value="15; A-202">Lecture : Non-Analytical Ways of Growth - $15 </option>
                                                <option value="15; A-203">Lecture : Creativity and Spirit in History and Today - $15 </option>
                                                <option value="15; A-202">Lecture : Active Methods of Spiritual Growth - $15 </option>
                                                <option value="15; A-205">Lecture : Walking Dream and Living Myth - $15 </option>
                                                <option value="15; A-206">Lecture : Moving Through Transitions - $15 </option>
                                                <option value="15;    A-207">Lecture : Finding Your Identity - $15 </option>
                                                <option value="15; A-208">Lecture : The Inner Development Process - $15 </option>
                                                <option value="15; A-209">Lecture : The Evolution of Self - $15 </option>
                                                <option value="15; A-210">Lecture : C.G. Jung and the Future - $15 </option>
                                                <option value="15; A-301">Interview : The Dialogue Concept - $15 </option>
                                                <option value="15; A-302">Interview : Beyond Psychotherapy - $15 </option>
                                                <option value="25; A-310">Interview : Both Interviews with Ira Progoff, PhD - A-310 - $25 </option>
                                                <!--<option>Book : The Symbolic and the Real (1963)
    </option><option>Book : Depth Psychology and the Modern Man (1959)
    </option><option>Book : The Dynamics of Hope (1985)
    </option><option>Book : The Death and Rebirth of Depth Psychology (1956)
    </option><option>Book : Jung's Psychology and Its Social Meaning (1953)
    </option><option>Book : Jung, Synchronicity and Human Destiny (1973)
    </option><option>Book : The Cloud of Unknowing (1957)
    </option><option>Book : The Image of an Oracle (1964)
    </option>-->
                                                <!--<option>Audio : The Well and the Cathedral (Book)
    </option>-->
                                            </select></td>
                                        <td class="generic"><input name="itemNo9" size="5" type="text"></td>
                                        <td class="generic"><input name="unitPrice9" size="5"  readonly="readonly" type="text"></td>
                                        <td class="generic"><input name="totalCost9" size="5" value="0.00" type="text"></td>
                                    </tr>
                                    <tr>
                                        <td class="generic">10.</td>
                                        <td class="generic"><input name="quantity10" value="1" size="2" onChange="calcTotal(this)" type="text"></td>
                                        <td class="generic"><select name="title10" onChange="calcTotal(this)">
                                                <option selected="selected">Select Item Title - Price </option>
                                                <option value="18.95;B-101">Book : At a Journal Workshop - $18.95 </option>
                                                <option value="18.95; B-102">Book : Life Study: Experiencing Creative Lives - $18.95 </option>
                                                <option value="195; A-401">Audio : All Audio CDs - $195 </option>
                                                <option value="15; A-101">Audio : The Well and the Cathedral (Audio) - $15 </option>
                                                <!--<option>Audio : The Star/Cross (Book)
    </option>-->
                                                <option value="15; A-102">Audio : The Star/Cross (Audio) - $15 </option>
                                                <!--<option>Audio : The White Robed Monk (Book)
    </option>-->
                                                <option value="15; A-103">Audio : The White Robed Monk (Audio) - $15 </option>
                                                <option value="40; A-104">Audio : Entrance Meditation™ Series (Audio) - $40 </option>
                                                <option value="15; A-201">Lecture : The Dialogue House Experience - $15 </option>
                                                <option value="15; A-202">Lecture : Non-Analytical Ways of Growth - $15 </option>
                                                <option value="15; A-203">Lecture : Creativity and Spirit in History and Today - $15 </option>
                                                <option value="15; A-202">Lecture : Active Methods of Spiritual Growth - $15 </option>
                                                <option value="15; A-205">Lecture : Walking Dream and Living Myth - $15 </option>
                                                <option value="15; A-206">Lecture : Moving Through Transitions - $15 </option>
                                                <option value="15;    A-207">Lecture : Finding Your Identity - $15 </option>
                                                <option value="15; A-208">Lecture : The Inner Development Process - $15 </option>
                                                <option value="15; A-209">Lecture : The Evolution of Self - $15 </option>
                                                <option value="15; A-210">Lecture : C.G. Jung and the Future - $15 </option>
                                                <option value="15; A-301">Interview : The Dialogue Concept - $15 </option>
                                                <option value="15; A-302">Interview : Beyond Psychotherapy - $15 </option>
                                                <option value="25; A-310">Interview : Both Interviews with Ira Progoff, PhD - A-310 - $25 </option>
                                                <!--<option>Book : The Symbolic and the Real (1963)
    </option><option>Book : Depth Psychology and the Modern Man (1959)
    </option><option>Book : The Dynamics of Hope (1985)
    </option><option>Book : The Death and Rebirth of Depth Psychology (1956)
    </option><option>Book : Jung's Psychology and Its Social Meaning (1953)
    </option><option>Book : Jung, Synchronicity and Human Destiny (1973)
    </option><option>Book : The Cloud of Unknowing (1957)
    </option><option>Book : The Image of an Oracle (1964)
    </option>-->
                                                <!--<option>Audio : The Well and the Cathedral (Book)
    </option>-->
                                            </select></td>
                                        <td class="generic"><input name="itemNo10" size="5" type="text"></td>
                                        <td class="generic"><input name="unitPrice10" size="5"  readonly="readonly" type="text"></td>
                                        <td class="generic"><input name="totalCost10" size="5" value="0.00" type="text"></td>
                                    </tr>
                                    <tr>
                                        <td class="generic" colspan="3">&nbsp;</td>
                                        <td class="generic" colspan="2">Subtotal</td>
                                        <td class="generic"><input name="orderTotal" size="5"  readonly="readonly" type="text"></td>
                                    </tr>
                                    <tr>
                                        <td class="generic" colspan="3">&nbsp;</td>
                                        <td class="generic" colspan="2">Shipping</td>
                                        <td class="generic"><input name="shipping" size="5" value="0.00" onChange="document.scriptForm.subTotal2.value = calcSubTotal2(document.scriptForm.shipping.value, document.scriptForm.addShipping.value); calcGrandTotal2();" type="text"></td>
                                    </tr>
                                    <tr>
                                        <td class="generic" colspan="3">&nbsp;</td>
                                        <td class="generic" colspan="2">Additional Shipping</td>
                                        <td class="generic"><input name="addShipping" size="5" value="0.00" onChange="document.scriptForm.subTotal2.value = calcSubTotal2(document.scriptForm.shipping.value, document.scriptForm.addShipping.value); calcGrandTotal2();" type="text"></td>
                                    </tr>
                                    <tr>
                                        <td class="generic" colspan="3">&nbsp;</td>
                                        <td class="generic" colspan="2">Subtotal</td>
                                        <td class="generic"><input name="subTotal2" size="5" value="0.00" type="text"></td>
                                    </tr>
                                    <tr>
                                        <td class="generic" colspan="3">&nbsp;</td>
                                        <td class="generic" colspan="2">Sales Tax (NY Residents)</td>
                                        <td class="generic"><input name="salesTax" size="5" value="0.00" type="text"></td>
                                    </tr>
                                    <tr>
                                        <td class="generic" colspan="3">&nbsp;</td>
                                        <td class="generic" colspan="2"><span class="smallTitle">GRAND TOTAL</span></td>
                                        <td class="generic"><input name="total" size="5" value="0.00" type="text"></td>
                                    </tr>
                                </table>
                                <br>
                                <center>
                                    <input name="submit" value="Review Order" type="submit">
                                </center>
                                <br>
                                <table class="popUp" cellpadding="0" cellspacing="0">
                                    <tbody>
                                        <tr>
                                            <td class="generic" colspan="4"><span class="smallTitle">Additional Charge Per Item - Shipping</span></td>
                                        </tr>
                                        <tr>
                                            <td class="generic">&nbsp;</td>
                                            <td class="generic">1st Item</td>
                                            <td class="generic">Each additional Item*</td>
                                        </tr>
                                        <tr>
                                            <td class="generic">United States</td>
                                            <td class="generic">$6.00</td>
                                            <td class="generic">$0.50</td>
                                        </tr>
                                        <tr>
                                            <td class="generic">Canada and Mexico</td>
                                            <td class="generic">$8.00</td>
                                            <td class="generic">$1.00</td>
                                        </tr>
                                        <tr>
                                            <td class="generic">Other Countries</td>
                                            <td class="generic">$10.00</td>
                                            <td class="generic">$1.50</td>
                                        </tr>
                                    </tbody>
                                </table>
                                <p>*Additonal charges may apply depending upon the order</p>
                                <p>The cost of shipping is based upon the number of books and audios. Example = three <i>Entrance Meditation</i> audios (code A-304) is three products, or $7 shipping in the United States.</p>
                                <p>To order the Introduction Combination or books that are out of print, please call 800-221-5844</p></td>
                        </tr>
                    </table>
                    </td>
                </tr>
            </tbody>
        </table>
    </center>
    </body>
    </html>

  4. #4
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,684
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by parajourn View Post
    Recently I've been building a form which allows the users to specify quantity and the items of their choice however for some reason I have been unable to calculate the subtotal automatically with Javascript so I wanted to see if anyone can provide a solution.
    You have a function called calcTotal() and a function called calcOrderTotal()
    When calcTotal has finished working out what it needs for the row, you should then call the calcOrderTotal() function to work out the subtotal.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  5. #5
    SitePoint Member
    Join Date
    May 2010
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey everyone,

    First off apologies for the late reply. I currently do consulting for multiple clients so I'm not always on top of their projects constantly. Apologies about the code blob but I just did that because in another forum they requested I add the entire sample after posting a snipplit so I thought it would be easier to just do it in one shot.

    Anyway, thank you pmw very much for your answer. It solved the issue perfectly.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •