troubleshooting Question

How can I calculate HTML form fields

Avatar of futr_vision
futr_vision asked on
JavaScriptHTML
8 Comments1 Solution191 ViewsLast Modified:
I have a form (see code below) where a user can input quantity of an item. I'd like to have the second text field populate(in the Total column) with the total price for each row and have the last text field in the last row calculate the sum of the Total column. How do you do this?
<table width="459" border="0" cellpadding="3">
              <tr>
                <td width="207" align="right">First Name: </td>
                <td colspan="3"><input type="text" name="fName" id="fName" /></td>
              </tr>
              <tr>
                <td align="right">Last Name:</td>
                <td colspan="3"><input type="text" name="lName" id="lName" /></td>
              </tr>
              <tr>
                <td align="right"><p>E-Mail:</p></td>
                <td colspan="3"><input type="text" name="email" id="email" /></td>
              </tr>
              <tr>
                <td align="right">Phone:</td>
                <td colspan="3"><input type="text" name="phone" id="phone" /></td>
              </tr>
              <tr>
                <td align="right">Fax:</td>
                <td colspan="3"><input type="text" name="fax" id="fax" /></td>
              </tr>
              <tr>
                <td align="right">&nbsp;</td>
                <td colspan="3">&nbsp;</td>
              </tr>
              <tr>
                <td align="right"><strong>PRODUCTS</strong></td>
                <td align="center"><strong>QTY</strong></td>
                <td align="left"><strong>PRICE</strong></td>
                <td align="left"><strong>TOTAL</strong></td>
              </tr>
              <tr>
                <td height="30" align="right"><strong>2004 <em>Cabernet Sauvignon</em></strong></td>
                <td width="32"><input name="wine8" type="text" id="wine8" size="5" /></td>
                <td width="72" align="left">                  x $9.28</td>
                <td width="114" align="left">=
                  <input name="textfield" type="text" id="textfield" size="8" /></td>
              </tr>
              <tr>
                <td align="right"><strong>2004  &nbsp;</strong><em><strong>Syra</strong></em><em><strong>h</strong></em>&nbsp;</td>
                <td><input name="wine9" type="text" id="wine9" size="5" /></td>
                <td align="left">                  x $9.28</td>
                <td align="left">=
                  <input name="textfield2" type="text" id="textfield2" size="8" /></td>
              </tr>
              <tr>
                <td align="right"><strong>2004 </strong><em><strong>LuminousBlend </strong></em></td>
                <td><input name="wine10" type="text" id="wine10" size="5" /></td>
                <td align="left">                  x $11.03</td>
                <td align="left">=
                  <input name="textfield3" type="text" id="textfield3" size="8" /></td>
              </tr>
              <tr>
                <td align="right"><strong>2004 </strong><em><strong>DuosBlend </strong></em></td>
                <td><input name="wine1" type="text" id="wine1" size="5" /></td>
                <td align="left">                  x $10.33</td>
                <td align="left">=
                  <input name="textfield4" type="text" id="textfield4" size="8" /></td>
              </tr>
              <tr>
                <td align="right"><strong>2002 <em>SuperTuscan</em> Blend </strong></td>
                <td><input name="wine2" type="text" id="wine2" size="5" /></td>
                <td align="left"> x $9.80</td>
                <td align="left">=
                  <input name="textfield5" type="text" id="textfield5" size="8" /></td>
              </tr>
              <tr>
                <td align="right"><strong>2002 <em>Syrah</em></strong></td>
                <td><input name="wine3" type="text" id="wine3" size="5" /></td>
                <td align="left"> x $9.28</td>
                <td align="left">=
                  <input name="textfield6" type="text" id="textfield6" size="8" /></td>
              </tr>
              <tr>
                <td align="right"><strong>2003 <em>SuperTuscan</em> Blend </strong></td>
                <td><input name="wine4" type="text" id="wine4" size="5" /></td>
                <td align="left"> x $10.50</td>
                <td align="left">=
                  <input name="textfield7" type="text" id="textfield7" size="8" /></td>
              </tr>
              <tr>
                <td align="right"><strong>2003 <em>Syrah</em></strong></td>
                <td><input name="wine5" type="text" id="wine5" size="5" /></td>
                <td align="left"> x $9.28</td>
                <td align="left">=
                  <input name="textfield8" type="text" id="textfield8" size="8" /></td>
              </tr>
              <tr>
                <td align="right"><strong>2004 <em>Accense - Sangiovese</em></strong></td>
                <td><input name="wine6" type="text" id="wine6" size="5" /></td>
                <td align="left"> x $9.10</td>
                <td align="left">=
                  <input name="textfield9" type="text" id="textfield9" size="8" /></td>
              </tr>
              <tr>
                <td align="right"><strong>2007 <em>Prelude - Viognier</em></strong></td>
                <td><input name="wine7" type="text" id="wine7" size="5" /></td>
                <td align="left"> x $7.70</td>
                <td align="left">=
                  <input name="textfield10" type="text" id="textfield10" size="8" /></td>
              </tr>
              <tr>
                <td height="35" align="right">&nbsp;</td>
                <td>&nbsp;</td>
                <td align="right"><strong>TOTAL:</strong></td>
                <td align="center"><input name="textfield11" type="text" id="textfield11" size="10" /></td>
              </tr>
              <tr>
                <td align="right">&nbsp;</td>
                <td colspan="3">&nbsp;</td>
              </tr>
              <tr>
                <td align="right">&nbsp;</td>
                <td colspan="3" align="center"><input type="submit" name="submit" id="submit" value="Place Order " /></td>
              </tr>
              <tr>
                <td align="right">&nbsp;</td>
                <td colspan="3">&nbsp;</td>
              </tr>
              <tr>
                <td align="right">&nbsp;</td>
                <td colspan="3">&nbsp;</td>
              </tr>
            </table>
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 8 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros