JavaScript

Moderators: None (Apply to moderate this forum)
Number of threads: 2058
Number of posts: 5158

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

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.