[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Formulas in HTML

Posted on 2004-10-21
2
Medium Priority
?
149 Views
Last Modified: 2010-04-09
How do I create a formula in HTML to reside on my website?  For example, I want the user to select a quantity from a drop-down box.  Once selected, I want that number to be multiplied by a cost per unit amount, invisible to the user.  The total amount should appear on the site.

Ex.  I want to order 5 hats, so I choose '5' from a drop-down box.  Each hat is $10.  Therefore, Total Cost = $50.00.  
0
Comment
Question by:BirdShooter
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 53

Accepted Solution

by:
Ryan Chong earned 375 total points
ID: 12377999
something like below will help?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<script language="JavaScript">
      function updatecost(v) {
            var wDoc1 = window.document;            
            var eDiv1 = document.all ? wDoc1.all["TotalCost"] : wDoc1.getElementById("TotalCost");
            eDiv1.innerHTML =  parseInt(v) * 10;
      }
      
</script>
<body>
<form name="form1" method="post" action="">
  Total Item
  <select name="totalitem" onChange="updatecost(this.value)">
    <option value="0"> </option>
      <option value="1">1</option>
    <option value="2">2</option>
      <option value="3">3</option>
      <option value="4">4</option>
      <option value="5">5</option>
  </select>
</form>
<p>
Total Cost ($):<div id="TotalCost"> 0</div>
&nbsp;</p></body>
</html>
0
 
LVL 53

Expert Comment

by:Ryan Chong
ID: 12378000
here is a better layout version:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<script language="JavaScript">
      function updatecost(v) {
            var wDoc1 = window.document;            
            var eDiv1 = document.all ? wDoc1.all["TotalCost"] : wDoc1.getElementById("TotalCost");
            eDiv1.innerHTML =  "Total Cost ($): " + parseInt(v) * 10;
      }
      
</script>
<body>
<form name="form1" method="post" action="">
  Total Item
  <select name="totalitem" onChange="updatecost(this.value)">
    <option value="0"> </option>
      <option value="1">1</option>
    <option value="2">2</option>
      <option value="3">3</option>
      <option value="4">4</option>
      <option value="5">5</option>
  </select>
</form>
<p>
<div id="TotalCost">Total Cost ($): 0</div>
&nbsp;</p></body>
</html>
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question