File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes prompt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "prompt" Watch "prompt" New topic
Author

prompt

Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
Is it possible to determine if the user has pressed the Cancel button in a prompt?


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Chris Baron
Ranch Hand

Joined: Mar 21, 2003
Posts: 1049
Hi Thomas,
just write the return value into a variable:

the same way is confirm() handeld
cb
[ October 06, 2003: Message edited by: Chris Baron ]
Chris Baron
Ranch Hand

Joined: Mar 21, 2003
Posts: 1049
Ok, this was too fast
Now i understand...it also alerts "Cancelled" if the Ok-Button was clicked and the inputfield is empty.
Sorry
[ October 06, 2003: Message edited by: Chris Baron ]
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
Let me explain what I want to do instead of asking roundabout questions. For the new JavaRanch forum, on the "reply" page I want to prompt the user for a URL and a name for the URL when they press the "url" button - similar to what we do in UBB. If the user presses "cancel" on the first prompt then I don't want to pop up the second prompt. UBB does it by asking for the URL first. If the user doesn't enter a URL then it assumes that it doesn't need the second prompt. Is this the only way to do this? Is there any difference between not entering anything on a prompt and hitting the "cancel" button? I am getting the impression that the "cancel" button is exaclty the same as "OK' with no data.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6

above is the ubb code....how they get around the cancel button is with the ==null with the return....that cancels out the function....
I am not sure what you are asking.....
Mani Ram
Ranch Hand

Joined: Mar 11, 2002
Posts: 1140

I tried to run this code. When I press Cancel, a null is returned and when I press Ok, the entered value is returned. So, you can check for a null.
[ October 06, 2003: Message edited by: Mani Ram ]

Mani
Quaerendo Invenietis
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
Suppose that I wanted to reverse the order of the prompts and ask for the text first and then the URL. If the user hits "cancel" on the first prompt then I want to forget the whole thing and not give them the second prompt. If they enter an empty string then I will give them the next prompt and simply display the URL that they enter as the text. My impression is that this can not be done in JavaScript.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15300
    
    6

Modified UBB code. I know this isn't exactly correct, but wouldn't something along these lines work?

[ October 06, 2003: Message edited by: Gregg Bolinger ]

GenRocket - Experts at Building Test Data
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: prompt