Jump to content

how to fire a script?


ballouta

Recommended Posts

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

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>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.