473,441 Members | 2,559 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,441 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 21822
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
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...
0
tracyyun
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...
0
isladogs
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.