Hi.
I'm looking for a javascript for the following scenario:
The visitor clicks a button and a Prompt box appears, where:
1. He clicks the Cancel button, typing nothing and a new page (null.html)
opens. Or,
2. He gives a wrong answer and an Alert pops-up, with "This is not the right
answer!" in it. So, he clicks Alert's OK button and the Prompt box re-opens
automatically. However, after three wrong answers a new page (sorry.html)
opens. Or,
3. When he gives the correct answer a new page (correct.html) opens.
Can someone help me please? Or am I asking too much?
--
Merlin dying to the Lady of the Lake:
"We lived our lives with passion and devotion"
--
Please, remove the TRAP to contact me
-- 7 1538
Andrew Thompson wrote: On Wed, 29 Sep 2004 01:26:20 +0300, geotso wrote:
2. He gives a wrong answer and an Alert pops-up, ...
2b. Whereupon he calls her, who (she) decodes the JS and tells him the password.
2c. Site cracked! ;-)
I know, I know... However it isn't a site. Is just a book for my little son.
So, can you help me now please?
Thanks.
BTW, sorry for I'm late. There was a problem with my ISP...
On Wed, 29 Sep 2004 18:08:07 +0300, geotso wrote: Andrew Thompson wrote: On Wed, 29 Sep 2004 01:26:20 +0300, geotso wrote:
2. He gives a wrong answer and an Alert pops-up, ...
... 2c. Site cracked! ;-)
I know, I know... However it isn't a site. Is just a book for my little son. So, can you help me now please?
Given I have never had need for such protection, no.
You might start with Google, though..
<http://www.google.com/search?q=javascript+password+download>
--
Andrew Thompson http://www.PhySci.org/codes/ Web & IT Help http://www.PhySci.org/ Open-source software suite http://www.1point1C.org/ Science & Technology http://www.lensescapes.com/ Images that escape the mundane
geotso said: Hi.
I'm looking for a javascript for the following scenario:
The visitor clicks a button and a Prompt box appears, where: 1. He clicks the Cancel button, typing nothing and a new page (null.html) opens. Or, 2. He gives a wrong answer and an Alert pops-up, with "This is not the right answer!" in it. So, he clicks Alert's OK button and the Prompt box re-opens automatically. However, after three wrong answers a new page (sorry.html) opens. Or, 3. When he gives the correct answer a new page (correct.html) opens.
Can someone help me please? Or am I asking too much?
<html>
<head>
<title>Demo</title>
<script type="text/javascript">
var attempts=3;
var question="What's your favorite color?";
var answer="blue";
function guard(){
while (attempts-->0) {
var response = prompt(question,"");
if (!response) {
location = "null.html";
}else if (response==answer) {
location = "correct.html";
} else {
alert("This is not the right answer!");
}
}
location="sorry.html";
}
</script>
</head>
<body onload="guard()">
<p>This page is blank</p>
</body>
</html>
Lee wrote: <html> <head> <title>Demo</title> <script type="text/javascript"> var attempts=3; var question="What's your favorite color?"; var answer="blue"; function guard(){ while (attempts-->0) { var response = prompt(question,""); if (!response) { location = "null.html"; }else if (response==answer) { location = "correct.html"; } else { alert("This is not the right answer!"); } } location="sorry.html"; } </script> </head> <body onload="guard()"> <p>This page is blank</p> </body> </html>
Lee,
Thank you very much for your try!
However:
I can't access the "correct.html, since after the right answer ("blue"), the
Prompt box pops-up again, the cursor looks busy, and the status bar tells me
that IE tries to open the "correct.html". Furthermore, even after three
right answers I go to the "sorry.html".
I have to click three times the Cancel before I go to "sorry.html". Can this
be done after only one click?
BTW I call the function from a button with onClick and not at the onLoad
time as in your example. Could this cause the described problems?
Thanks again for your patience!
geotso said: Lee wrote: <html> <head> <title>Demo</title> <script type="text/javascript"> var attempts=3; var question="What's your favorite color?"; var answer="blue"; function guard(){ while (attempts-->0) { var response = prompt(question,""); if (!response) { location = "null.html"; }else if (response==answer) { location = "correct.html"; } else { alert("This is not the right answer!"); } } location="sorry.html"; } </script> </head> <body onload="guard()"> <p>This page is blank</p> </body> </html>
Lee,
Thank you very much for your try!
However: I can't access the "correct.html, since after the right answer ("blue"), the Prompt box pops-up again, the cursor looks busy, and the status bar tells me that IE tries to open the "correct.html". Furthermore, even after three right answers I go to the "sorry.html".
I have to click three times the Cancel before I go to "sorry.html". Can this be done after only one click?
The problem is that I dislike Internet Explorer so much
these days that I don't generally bother to test in it.
This version works in IE as well as in decent browsers:
<script type="text/javascript">
var attempts=3;
var question="What's your favorite color?";
var answer="blue";
var newpage="sorry.html";
function guard(){
while (attempts-->0) {
var response = prompt(question,"");
if (!response) {
newpage = "null.html";
break;
}else if (response==answer) {
newpage = "correct.html";
break;
} else {
alert("This is not the right answer!");
}
}
location=newpage;
}
</script>
my goodness!
thank you so much, Lee! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Cooper |
last post by:
Hello,
i have a form with TEXT, SELECT etc, elements. Simple, i suppose two TEXT
(name: T1 and T2). If a user insert a bad value, it display a error message
and turn back at form.
My problem is:...
|
by: Hans |
last post by:
Hi!
I have an asp application where I use a lot of javascript for validations
etc and as it is today I use alert, confirm and prompt dialogs. Now we are
adding support for unicode and I have...
|
by: Grey |
last post by:
I need to prompt out an alert box when I finished some server programming in ASP.NET. But I don't know how. Please advise me the way.
Million Thanks
|
by: J.P. Cummins |
last post by:
In my ASP.NET application, I wish to have a page for administrators to
edit items in a list. Preferably, I would like to use the javascript
prompt for the 'rename' function, and a javascript alert...
|
by: lisaj |
last post by:
I'm having huge difficulties producing a script for this:
Write a javascript programme that will prompt for, and accept from the user, an input string which contains at least 8 characters. It...
| |
by: andwing |
last post by:
<form method="post" name="folder" id="folder">
<input type="hidden" name="name" value="" />
<input name="submit" type="hidden" value="new name .."
onclick="getname();" />
function getname ()
{...
|
by: hcross |
last post by:
This project is a web based html and Javascript site. I am working on mac at the moment. This script works except for attempting to open new window once complete.
As you can see, i am new to...
|
by: vjsv2007 |
last post by:
Can you help to make one alert with all details?
<script type="text/javascript">
<!--
function validate_form ( )
{
valid = true;
|
by: Computer Guru |
last post by:
Prompts and alerts are usually one lined. However, my prompt statement is rather long and does not fit on one line. With js alerts I use something like this...
<a...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |