JavaScript

Moderators: None (Apply to moderate this forum)
Number of threads: 2061
Number of posts: 5164

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Multiply an entry Posted by webuser on 12 Dec 2005 at 6:27 AM
I want to add a script to multiply an user input and
show the result beside the input text box. Is there
any one to help?
Report
Re: Multiply an entry Posted by mac_doggie on 25 Mar 2006 at 3:53 AM
I don't know if you still need it, but I think you need something like this...?


<html>
   <head>
      <script type="text/JavaScript"    Language="JavaScript">
      function Multiply() {
         document.getElementById('result').innerText =  document.getElementById('userinput').value * 3;
      }
      </script>
   </head>
   <body>
      <input type="text" id="userinput" onchange="Multiply();"><span id="result"></span> 
   </body>
</html>


: I want to add a script to multiply an user input and
: show the result beside the input text box. Is there
: any one to help?
:


-mac-
mailto:mac_doggie@hotmail.com
the Netherlands...


Report
Re: Multiply an entry Posted by webuser on 26 Mar 2006 at 9:10 PM
Dear mac, I used this:

<html>
<head>
<script type="text/JavaScript" Language="JavaScript">
function TotalCost()
{
if (document.MainForm.BookNumber.value<1)
{document.MainForm.Cost.value="NaN";}
else {document.MainForm.Cost.value=document.MainForm.BookNumber.value*600+100}
}
</script>
</head>
<body>
<input onblur=TotalCost(); onchange=TotalCost(); type="text" name="BookNumber" value="1">
</body>
</html>

What's your idea?
Report
Re: Multiply an entry Posted by mac_doggie on 27 Mar 2006 at 8:03 AM
I think that will work also, but I prefer using the document.getElementById() function to avoid problems with different browsers...

-mac-

: Dear mac, I used this:
:
: <html>
: <head>
: <script type="text/JavaScript" Language="JavaScript">
: function TotalCost()
: {
: if (document.MainForm.BookNumber.value<1)
: {document.MainForm.Cost.value="NaN";}
: else {document.MainForm.Cost.value=document.MainForm.BookNumber.value*600+100}
: }
: </script>
: </head>
: <body>
: <input onblur=TotalCost(); onchange=TotalCost(); type="text" name="BookNumber" value="1">
: </body>
: </html>
:
: What's your idea?
:


-mac-
mailto:mac_doggie@hotmail.com
the Netherlands...





 

Recent Jobs