WeLoveCSS

WeLoveCSS (http://welovecss.com/index.php)
-   Scripting and Server Side (http://welovecss.com/forumdisplay.php?f=7)
-   -   Need advice on javascript loop problem? (http://welovecss.com/showthread.php?t=9106)

sam1203 27th January 14 09:56 AM

Need advice on javascript loop problem?
 
I am having trouble creating this javascript problem:

“Create a web page called “wartime.html” that consists of a textarea and a button which reads “Shoot the Cannon Until Surrender”. If the button is clicked, the program enters a loop that repeatedly prompts the user “Do you surrender, yes or no?”. If the user types “yes” or “y”, add the phrase “The war is over” to the text area and exit the loop. If the user types anything else, add the phrase “BOOM” to the textarea and prompt again for surrender.”

This is what I have so far for my function:

War Time

function decide() { var n1 = prompt(“Do you surrender? Yes or no?”, “”); document.getElementById(‘battlefield’).v… var counter=0 while (n1 == yes) {document.getElementById(“battlefield”)…. += “The war is over!”} }

h2{text-align=center} p{text-align=center}

War Time!

I am unsure as to what I have to do to make the loop respond to the user’s input

meesa 27th January 14 11:10 AM

Re: Need advice on javascript loop problem?
 
Your code appears to have been truncated. Please edit your original post and place all code in [code] tags. Also make sure you're lines aren't too long.

sam1203 27th January 14 11:15 AM

Re: Need advice on javascript loop problem?
 
Quote:

Originally Posted by meesa (Post 37941)
Your code appears to have been truncated. Please edit your original post and place all code in [code] tags. Also make sure you're lines aren't too long.

i did'n get you so please can you send me it's basic tamplate ?
please

meesa 27th January 14 11:20 AM

Re: Need advice on javascript loop problem?
 
Repost your code. Place everything between [code] tags.


All times are GMT. The time now is 06:05 AM.

Powered by vBulletin Version 3.8.4 Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.