ballouta Posted February 5, 2011 Share Posted February 5, 2011 Hello I am studying JavaScript at college. there are some examples in the book and I would like to test them. example: var age = parseInt (prompt ("Please entger your age"); alert ("Your age in decimal is " + age); How can I test this script? I added : <script type="text/javascript" src="fig 7-2.js"></script> in the head of the HTML. then what? Thank You Link to comment https://forums.phpfreaks.com/topic/226733-how-to-fire-a-script/ Share on other sites More sharing options...
sunfighter Posted February 5, 2011 Share Posted February 5, 2011 parseInt converts to a integer so age in decimal aint right. Make the js a function and call it from a button. <body> <script type="text/javascript"> function lookie() { var age = parseInt(prompt("Please enter your age","")); alert ("Your age in decimal is " + age); } </script> <input type="button" onclick="lookie()" value="My Age"> </body> </html> Link to comment https://forums.phpfreaks.com/topic/226733-how-to-fire-a-script/#findComment-1170439 Share on other sites More sharing options...
ballouta Posted February 5, 2011 Author Share Posted February 5, 2011 Thank You Link to comment https://forums.phpfreaks.com/topic/226733-how-to-fire-a-script/#findComment-1170441 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.