JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 18th, 2012, 06:12 AM
djdigitalgirl99 djdigitalgirl99 is offline
Permanently Banned
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2012
Posts: 3 djdigitalgirl99 Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 19 m 33 sec
Warnings Level: 10
Number of bans: 1
Reputation Power: 0
Ok so I need help in understanding 'while' loops and using them.
If someone clicks no in a dialogue box, how can I get it to loop back to the original question? And how can I keep it looping until the value is true?
with the javascipt im using we have the following dialogue boxes:
alert (simple press ok to carry on)
confirm (a yes or no box)
request (the user has to type something ot carry on)
So for example:

String newNum = request("Please enter a new number you would like");
String confirmNew = request("Please confirm the new number");
if (newNum.equals(""+confirmNew))
{
alert("The new number has been processed");
}
else
{
confirm("The two numbers entered did not match. Try again?");
}

So if the user clicks yes to trying again how can I loop back to the start? And if the user clicked no how can I put an alert dialogue box to say "Cancelled" ?

Thank you for any help given! I got the basics but I cant work out looping!!
Comments on this post
ptr2void disagrees: Go away, useless SEO spammer

Last edited by ManiacDan : September 18th, 2012 at 07:06 AM.

Reply With Quote
  #2  
Old September 18th, 2012, 06:23 AM
badger_fruit's Avatar
badger_fruit badger_fruit is offline
Confused badger
Dev Shed Novice (500 - 999 posts)
 
Join Date: Mar 2009
Location: West Yorkshire
Posts: 760 badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 5 h 15 m 18 sec
Reputation Power: 339
Quote:
Originally Posted by djdigitalgirl99
Ok so I need help in understanding 'while' loops and using them.
If someone clicks no in a dialogue box, how can I get it to loop back to the original question? And how can I keep it looping until the value is true?
with the javascipt im using we have the following dialogue boxes:
alert (simple press ok to carry on)
confirm (a yes or no box)
request (the user has to type something ot carry on)
So for example:

String newNum = request("Please enter a new number you would like");
String confirmNew = request("Please confirm the new number");
if (newNum.equals(""+confirmNew))
{
alert("The new number has been processed");
}
else
{
confirm("The two numbers entered did not match. Try again?");
}

So if the user clicks yes to trying again how can I loop back to the start? And if the user clicked no how can I put an alert dialogue box to say "Cancelled" ?

Thank you for any help given! I got the basics but I cant work out looping!!


djdigitalgirl[dot]com


Hi there

Couple of quick things:-
1. You've posted a Javascript question in a PHP forum, a mod should move this if you're wanting help with Javascript.
2. You should post code in appropriate tags.

Ok, now they're out of the way ...
The code you posted is an IF / ELSE so will only execute ONCE. A "While" loop will loop until a certain condition is met (which you define at the start of the loop).

For example, in PHP you would write:

PHP Code:
<?php
// Give $x an initial value, 4 in this case
$x 4;

// Configure the while loop, in this case, WHILE X is not 0, perform the loop
while ($x != 0) {
  
// Display the current value of $x
  
echo $x "<br />";

  
// Take 1 away from $x
  
$x--;
}

// When $x reaches 0, this bit of code is then executed
echo "Done!";

?>


With regards to your Javascript question, this link should answer all your questions.
__________________
The number for UK Emergencies is changing, the new number is 0118 999 881 999 119 7253

"For if leisure and security were enjoyed by all alike, the great mass of human beings who are normally stupefied by poverty would become literate and would learn to think for themselves; and when once they had done this, they would sooner or later realise that the privileged minority had no function and they would sweep it away"
- George Orwell, 1984

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > Can't get loops in JS

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap