Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to multiply in HTML

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Could somebody tell me how to multiply in HTML. The sign * does not work?
 
It should, try it again. If you have expressions make sure to enclose them in brackets. And make sure you are using something that can at least be converted to a number.
(Which is done automatically - no need to parseInt)

Code:
<html>

<head>
     <script language=&quot;javascript&quot;>
     function multiply(){
     var ans= (document.form.one.value)*(document.form.two.value)
     document.form.answer.value=ans;
     }
     </script>


</head>

<body><form name=&quot;form&quot;>
<input type=&quot;text&quot; name=&quot;one&quot; size=&quot;2&quot;>
<input type=&quot;text&quot; name=&quot;two&quot; size=&quot;2&quot;>
<input type=&quot;text&quot; name=&quot;answer&quot; size=&quot;2&quot;>
<input type=&quot;button&quot; value=&quot;answer&quot; name=&quot;now&quot; onClick=&quot;multiply()&quot;></form>
</body>

</html>

Hope it helps, BJ.
 
No you cannot multiply in HTML. It is a mark-up language, not a programming language. However, as bangers pointed out, you can use JavaScript to do it.
Sincerely,

Tom Anderson
CEO, Order amid Chaos, Inc.
 
Sorry, I thought that's what he/she meant!
 
The javascript is great. I can use it. Thanks both for your input. As a starting html-er I can use every input

Ralph
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top