Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: I'm REALLY new


Message #1 by "Sam Chavez" <sam_chavez@h...> on Sat, 24 Mar 2001 03:34:23
> Hi im REALLY very new to html and javascript but I got stuck on a 
question 
> that bothers me a lot.
> 
> <script language="javascript">
> 
>   var firstNumber = prompt("enter the first number", "");
>   var secondNumber = prompt("enter the second number", "");
>   var theTotal = firstNumber + secondNumber;
> 
>   document.write(firstNumber + " added to " + secondNumber + " equals " 
+ 
> theTotal);
> 
> </script>
> 
> I relize what the problem is ( the + in theTotal var) but i dont know 
what 
> to do to make it work.
> Any help to a newbie is appreciated =).
> 
Ok, this is all you have to do:

var firstNumber = parseInt(prompt("enter the first number", ""));
var secondNumber = parseInt(prompt("enter the second number", ""));

or substitute parseInt for parseFloat, for a floating point number.

  Return to Index