![]() |
I cannot find the bug.
I wrote this little code to put a few skills together to make sure I am understanding the logic correctly.
*Code runs a prompt asking for your name *Take the name and runs a prompt to ask your age. *I have loops set up to make sure the fields are filled out correctly, if not it re-runs the prompt. *The prompt to ask the age, keeps looping, I have the parameters set correctly it looks like, but it won't accept any number to end the loop. **I emboldened the few lines of code I am having an issue with. Thanks, Russell Code:
var counter= 0 |
didnt read it all, but while(counter2 = 1) should def be while(counter2 == 1)
|
update
I did some more tinkering around with it, and I found the bug is in a different area of the code (new emboldened lines)
Code:
var counter= 0; |
Code:
while(counter= 1){ |
You shouldn't be using either prompt or document.write in your javaScript - those became obsolete a long time ago.
|
Quote:
But if you insist on using prompt, here is the best way to require a valid entry- Code:
<script type = "text/javascript">Code:
<script type = "text/javascript"> |
Slightly simpler:
Code:
while( true ) Code:
while( true ) |
Of course none of those approaches will prevent a visitor using any browser except Internet Explorer from simply checking the checkbox at the bottom of the prompt either on its first appearance in Opera - where it turns off JavaScript - or on its second appearance in other browsers - where it turns off all further prompts, confirms and alerts.
|
it runs
Thanks for the feedback yall, using values of true/false/null helped it run along with my mistakes of = instead of ==.
Code:
|
| All times are GMT +1. The time now is 09:36 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.