WeLoveCSS Logo
Home Profile Members Search Rules Help New Posts



WeLoveCSS > PROGRAMMING LANGUAGES > Scripting and Server Side > Need advice on javascript loop problem?

Reply
  Thread Tools Display Modes
Old 27th January 14, 08:56 AM   #1
sam1203
WLC Member
 
Join Date: Jan 2014
Posts: 5
Default 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

Last edited by meesa; 27th January 14 at 10:19 AM.
sam1203 is offline   Reply With Quote
Old 27th January 14, 10:10 AM   #2
meesa
WLC Mod
 
meesa's Avatar
 
Join Date: Jul 2009
Location: Milky Way Galaxy
Posts: 3,709
Default 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.
__________________
Praise be to the Lord God for the ability to learn, the capability to analyze, and the time to help users on this forum.
meesa is offline   Reply With Quote
Old 27th January 14, 10:15 AM   #3
sam1203
WLC Member
 
Join Date: Jan 2014
Posts: 5
Default Re: Need advice on javascript loop problem?

Quote:
Originally Posted by meesa View Post
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
sam1203 is offline   Reply With Quote
Old 27th January 14, 10:20 AM   #4
meesa
WLC Mod
 
meesa's Avatar
 
Join Date: Jul 2009
Location: Milky Way Galaxy
Posts: 3,709
Default Re: Need advice on javascript loop problem?

Repost your code. Place everything between [code] tags.
__________________
Praise be to the Lord God for the ability to learn, the capability to analyze, and the time to help users on this forum.
meesa is offline   Reply With Quote
Reply


Thread Tools
Display Modes
Linear Mode Linear Mode

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:47 AM.



Home | Advertise | Contact Us | Top
Home | Advertise | Contact Us | Top

Copyrightę 2006 WeLoveCSS.com. All Rights Reserved.
Powered by vBulletin Version 3.8.4 Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.