473,574 Members | 2,389 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 21842
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.javas cript 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
7481
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 I've read explains about setting the flag to bring up the overwrite prompt message box, but there's no explanation on how to read the response to it....
3
9040
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 method that can do it?
7
19268
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 it to be centered so... I was doing some research on the net (never really used much JavaScript before) and was reading the only way to do this is...
1
8328
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 but that's the gist of it.) I have everything set up, and it seems to work except that setting Cancel to true and returning from my c# method appears...
4
2870
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 applicable code: do { var f=prompt('Would you like the output to be displayed in this page (1) or as a pop-up (2)','1'); } while (f != "1" &&...
2
2306
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 other browsers just provide a single-line prompt text box, meaning that the user hitting ENTER is the same as them hitting the "Ok" button. In...
8
11589
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 replace" dialog, the DialogResult is Cancel instead of OK. Is there something I am missing? Dim lSaveFileDialog As New SaveFileDialog
1
2664
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 action="/submitCustomerForm"> <bean:message key="prompt.customer.firstname"/>
1
2234
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 “department” prompt but leaves the “access” prompt empty or clicks cancel, I want the Alert Message List to look… ...
0
7720
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8230
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6451
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5618
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5299
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3749
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2240
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1337
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1056
bsmnconsultancy
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.