473,383 Members | 1,877 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Prompt - Cancel/OK Result?

Hi there,

Does the prompt method return a value indicating which button the user
pressed (OK or Cancel) ? If so, how can I access this as it just seems
to return the text the user entered?

Thanks,

Chris

Jan 13 '06 #1
3 21815
Chris Ashley wrote:
Does the prompt method return a value indicating which button
the user pressed (OK or Cancel) ?
If so, how can I access this as it just seems > to return the text
the user entered?


If user clicked OK, the value is not null.
If user clicked Cancel, the value is null.

var p;
p = prompt('What is your age ?','');

if (p == null) {
alert('Cancel was clicked.');
}
else {
alert('OK was clicked.');
}

--
Bart

Jan 13 '06 #2
Bart Van der Donck said the following on 1/13/2006 11:28 AM:
Chris Ashley wrote:

Does the prompt method return a value indicating which button
the user pressed (OK or Cancel) ?
If so, how can I access this as it just seems > to return the text
the user entered?

If user clicked OK, the value is not null.
If user clicked Cancel, the value is null.


And if user clicked the X the value is null.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jan 13 '06 #3
Randy Webb wrote:
Bart Van der Donck said the following on 1/13/2006 11:28 AM:
If user clicked OK, the value is not null.
If user clicked Cancel, the value is null.


And if user clicked the X the value is null.


And if user pressed Escape the value is null.

--
Bart

Jan 13 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Gord | last post by:
Hello, If you set the flag for an overwrite prompt using the 'Save' common dialog, how do you read the response when the user clicks the Yes or No in the 'overwrite' message box? Everything...
3
by: nuno silva | last post by:
i'm new to javascript, and so I'd like to know if there's a way to make a prompt box, that, instead of having "ok" "cancel" and a text box, would just have buttons of "yes" "no". Is there a...
7
by: Petesman | last post by:
I am trying to make a prompt that will ask the user for some input... If I just use var input = prompt("dafa") everything works fine but the box is put in the top left corner of the window. I need...
1
by: AP | last post by:
Hi, I'm trying to use c# to pop up a dialog box when a user attempts to close word to prompt them if they want to exit or cancel (obviously other stuff needs to happen based on their selection...
4
by: navyjax2 | last post by:
My question is closely related to http://www.thescripts.com/forum/thread444945.html and was not answered there, so I figured I'd revive it since I think I have the same issue. Here is my...
2
by: Greg Taylor | last post by:
Greetings, I was wondering if there was a way to make prompt() calls in Safari show a single-line input box instead of the default multi-line prompt that it currently does. It seems like most...
8
by: Joe Duchtel | last post by:
Hello - I have the following code to detemine a file name when my application is saving a file. The problem is that if the file already exists and I select the Yes button in the "Do you want to...
1
by: ramprakashjava | last post by:
hi , i hav this error while running this customerDetails.jsp <html:html> <head> <html:base/> </head> <body> <html:errors/> <html:form...
1
by: cruzzer | last post by:
I need to know how can I exclude a data item from the Alert Window’s list message if the user leaves a prompt window blank. Example : If the user types a value to both “idnumber” and...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.