Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

prompt

 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible to determine if the user has pressed the Cancel button in a prompt?
 
Chris Baron
Ranch Hand
Posts: 1061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 1140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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 ]
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic