Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

refresh

Status
Not open for further replies.

chrisgarvey

Technical User
Mar 27, 2003
64
GB
I have the following very simple program, shown below.

I am a newbe to HTML.

I am trying change the below so after the user has entered anything into the command prompt & pressed enter. It automatically refreshes the page with an command prompt.

Any help would be much appreciated.

Chris

<HTML>
<HEAD>

<TITLE>Double it</TITLE>

</HEAD>
<BODY>

<H1>Doubller</H1>
<script language=&quot;JavaScript&quot;>


//ask the use for a number and try to convert the input into a number
var userNumber = Number(prompt(&quot;Enter a number between 1 and 10&quot;,&quot;&quot;));

//if the value of userNumber is NaN then ask the user to try again
if (isNaN(userNumber))
{
document.write(&quot;Please ensure a valid number is entered&quot;);
}

//if the value is a number but over 10 then ask the user to try again
else
{
if (userNumber > 10 || userNumber < 1)
{
document.write(&quot;The number you entered is not between 1 and 10&quot;);
}

//otherwise the number is between 1 and 10 so write to the screen
else
{
document.write(&quot;The number you entered was &quot; + userNumber);
document.write(&quot;<br />&quot;);
document.write(&quot;The number doublled is &quot; + userNumber * '2');

}
}

</script>
</BODY>
</HTML>
 
Thanks for your help Jeff,

Got it to work.

Used

window.location.reload();

Chris.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top