aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Help on how to change caption of Confirm box in JSP 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 "Help on how to change caption of Confirm box in JSP" Watch "Help on how to change caption of Confirm box in JSP" New topic
Author

Help on how to change caption of Confirm box in JSP

Viidhya Kishore
Ranch Hand

Joined: Jan 03, 2007
Posts: 99
Hi,
I have a requirement to change the text of a confirm box displayed to user from "OK" and "CANCEL" to "SAVE" and "DO NOT SAVE"

Can some one please help me with it as I am really new to this.
I am using the javascript to get the OK/CANCEL box butnot sure how to change the caption of it.

Thanks in advance.

Shriya
[ June 18, 2008: Message edited by: Shriya Kishore ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61648
    
  67

Please be sure to post HTML and JavaScript questions in the HTML forum. I've moved this there for you,


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61648
    
  67

You can't, sorry.

You'll either need to live with the defaults, or make your own confirm box. If you are a beginner, that may be a bit complex for you at the moment.
Viidhya Kishore
Ranch Hand

Joined: Jan 03, 2007
Posts: 99
Can you give me an idea how to create your own custom box.

This is a requirement and I have to get it done.

Please help.

Shriya
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61648
    
  67

You'll need to use a <div> element, absolutely positioned and z-indexed over the other elements. Style it to look like a mini-dialog perhaps. You'll need to capture and discard events from the rest of the page if you want it to act like a modal dialog. (The easiest way to do that is actually to cover the page with an invisible or translucent div that floats over the page, but under the modal "dialog").
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61648
    
  67

An example of such a faux modal dialog can be seen at http://www.bibeault.org/blackbox. Click on the "Play the game" button to see the example.
Viidhya Kishore
Ranch Hand

Joined: Jan 03, 2007
Posts: 99
Will it be right to open a pop up window and make it look like a dialog?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61648
    
  67

You could go that way, but that introduces a whole lot of new issues. You can't make it modal (at least in a cross-browser fashion), it could end up hidden behind the main window, and users could just ignore it. Not to mention the extra complexity of cross-window communications.

Personally, I would not go that route.
Viidhya Kishore
Ranch Hand

Joined: Jan 03, 2007
Posts: 99
But I dod not understand your previous suggestion.
Can I find something of that sort on the net.

If you could provide a code snippent,
it will help me immensely.
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30929
    
158

Shriya,
Bear did post a link to the code. It is a lot more complicated than a normal confirm box. Has your user confirmed that they want the requirement even at the cost? Sometimes requirements go away because the user didn't realize how hard they were. After all, changing names doesn't sound tricky unless you are a developer.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Viidhya Kishore
Ranch Hand

Joined: Jan 03, 2007
Posts: 99
I am afraid yes...
The requirement is very much there and we are just not able to negotiate it.

The link does not have the code.
It merely has the example.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61648
    
  67

All JavaScript is always available from a site. If you examine the source, you will see that the script files are readily available.

Be aware that BlackBox uses jQuery as a JavaScript library.
Viidhya Kishore
Ranch Hand

Joined: Jan 03, 2007
Posts: 99
When I do a "view Source" the name of the script is mentioned but it is not downloaded in my temp files.

How can I get hold of the .js file?

Please help.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61648
    
  67

So in the View Source, you see something like:

You can see the URL of the script file. Just use your browser to hit the URL and download the script.
Viidhya Kishore
Ranch Hand

Joined: Jan 03, 2007
Posts: 99
OK.
With all your help.
I have successfully opened a pop up window from the main JSP and show 2 buttons for save and cancel.
Now the problem is :
previously the code was :
var str = 'Your query has not been saved. Do you want to save the query?\n' +'\n\tPress "OK" to save the query.' +
'\n\tPress "Cancel" to run the query without saving it.';
if (confirm(str)) {
return saveQuery(executeAfterSave);
}

Now I need to perform the same thing but when save button is clicked in the popup window,i.e on click of save,tehh method in .js file has to be called and the popup should close.
The above code is in .js file.

Please help.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help on how to change caption of Confirm box in JSP