Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #21 (permalink)  
Old May 25th, 2005, 11:09 AM
Friend of Wrox
Points: 8,019, Level: 38
Points: 8,019, Level: 38 Points: 8,019, Level: 38 Points: 8,019, Level: 38
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2005
Location: Mauchline, East Ayrshire, Scotland
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default

ok, thanks for your help.

www.crmpicco.co.uk
www.crmpicco.co.uk.tt
www.milklemonadechocolate.uk.tt
www.griswolds.uk.tt
www.piccosmini.co.uk.tt
www.morton.uk.tt
Reply With Quote
  #22 (permalink)  
Old May 25th, 2005, 11:15 AM
Friend of Wrox
Points: 8,019, Level: 38
Points: 8,019, Level: 38 Points: 8,019, Level: 38 Points: 8,019, Level: 38
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2005
Location: Mauchline, East Ayrshire, Scotland
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default

oh, btw, can i have a 'OK' button in the showModal and not just a hyperlink

www.crmpicco.co.uk
www.crmpicco.co.uk.tt
www.milklemonadechocolate.uk.tt
www.griswolds.uk.tt
www.piccosmini.co.uk.tt
www.morton.uk.tt
Reply With Quote
  #23 (permalink)  
Old May 25th, 2005, 11:20 AM
Friend of Wrox
 
Join Date: Jul 2003
Location: , , United Kingdom.
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Sure, just do something like...
Code:
<input type="button" value="OK" onclick="returnOk();" />
...
function returnOk(){
    window.returnValue = true;
    window.close();
}
Reply With Quote
  #24 (permalink)  
Old May 25th, 2005, 11:30 AM
Friend of Wrox
Points: 8,019, Level: 38
Points: 8,019, Level: 38 Points: 8,019, Level: 38 Points: 8,019, Level: 38
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2005
Location: Mauchline, East Ayrshire, Scotland
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default

have you got an example of how to code this, on the www?

www.crmpicco.co.uk
www.crmpicco.co.uk.tt
www.milklemonadechocolate.uk.tt
www.griswolds.uk.tt
www.piccosmini.co.uk.tt
www.morton.uk.tt
Reply With Quote
  #25 (permalink)  
Old May 26th, 2005, 06:34 AM
Friend of Wrox
 
Join Date: Jul 2003
Location: , , United Kingdom.
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Save this as alert.htm...
Code:
<html>

<head>
<style type="text/css">
body{
    background-color: buttonface;
    overflow: hidden;
}
body, input{
    text-align: center;
    font-size: 8pt;
    font-family: MS Sans Serif;
}
input{
    height: 23px;
    width: 75px;
}
#myMessageDiv{
    padding: 15px;
}
</style>
<script type="text/javascript" language="javascript">
function Init(){
    document.getElementById("myMessageDiv").appendChild(document.createTextNode(window.dialogArguments));
}
function returnOk(){
    window.returnValue = true;
    window.close();
}    
</script>
</head>

<body onload="Init();">
<div id="myMessageDiv"></div>
<input type="button" value="OK" onclick="returnOk();" />
</body>

</html>
then in your page where you want to show it just add...
Code:
showModalDialog('alert.htm', 'my message', 'dialogWidth: 200px; dialogHeight: 120px; help: no;')
(you will need to adjust width / height depending on your message)

Reply With Quote
  #26 (permalink)  
Old May 26th, 2005, 09:06 AM
Friend of Wrox
Points: 8,019, Level: 38
Points: 8,019, Level: 38 Points: 8,019, Level: 38 Points: 8,019, Level: 38
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2005
Location: Mauchline, East Ayrshire, Scotland
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default

thats great, i'll give it a try and get back to you

www.crmpicco.co.uk
www.crmpicco.co.uk.tt
www.milklemonadechocolate.uk.tt
www.griswolds.uk.tt
www.piccosmini.co.uk.tt
www.morton.uk.tt
Reply With Quote
  #27 (permalink)  
Old June 24th, 2008, 09:44 AM
Registered User
 
Join Date: Jun 2008
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to shriyakish
Default

Hello,
I was browsing through your topic and this was pretty much what I am looking for but with some differences.
I took the liberty to try out the code above and it works amazingly.
However,I need to display a message above the boxes and also have a "question mary icon(?)" on the left hand side.

Please tell em how to do that.
Also,I am opening this dialog box from a js so I need to call a different method from the js depending on the true or false.
So how can I catch the true/false from the dialog into the js.

Please help as this is an urgent requirement from the client.

P.S : if you could provide some link to understand the custom dialogs it will be very helpful.

Reply With Quote
  #28 (permalink)  
Old March 25th, 2010, 10:43 AM
Authorized User
 
Join Date: Jan 2010
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to elizas Send a message via Skype™ to elizas
Default How to create a customized confirmation alert in javascript

When you implement a delete feature in your application, a very basic additional feature which is always expected to be implemented is a confirmation box, so that the user gets a prompt before doing some delete activity.

For implementing this, there is already a Javascript function called confirm().
The syntax for this is very simple and i am sure every developer is aware of this. The syntax is as follow:

var confirm = confirm("Are you sure you want to do this?");
if(confirm)
{
//do your delete operation
}
else
{
return false;
}
Hope this answer helped u.
__________________
Cheers,
Eliza

Mindfire: India's Only Company to be both Apple Premier & Microsoft Gold certified.
Reply With Quote
  #29 (permalink)  
Old March 12th, 2014, 07:44 AM
Registered User
Points: 3, Level: 1
Points: 3, Level: 1 Points: 3, Level: 1 Points: 3, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2014
Location: San Francisco, CA, USA
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Re:Does your post include code? Use the [code] and [/code] tags before and after code

Quote:
Originally Posted by elizas View Post
When you implement a delete feature in your application, a very basic additional feature which is always expected to be implemented is a confirmation box, so that the user gets a prompt before doing some delete activity.

For implementing this, there is already a Javascript function called confirm().
The syntax for this is very simple and i am sure every developer is aware of this. The syntax is as follow:

var confirm = confirm("Are you sure you want to do this?");
if(confirm)
{
//do your delete operation
}
else
{
return false;
}
Hope this answer helped u.
Yes I understood what you said. Actually when I designed apps for my iPhone then I felt hurdles from JavaScript specially related to delete feature in my app. But now, this problem has been solved. Thanks mate :-)
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
JavaScript Confirm Box ricespn Classic ASP Basics 1 January 20th, 2007 12:48 AM
Javascript Confirm Message box itHighway Javascript How-To 5 September 25th, 2006 03:51 AM
Confirm Button after update fixitman Access 2 April 12th, 2004 04:28 PM
Confirm alert box - need help, Please! larry HTML Code Clinic 1 January 25th, 2004 02:07 AM
how to default confirm box to NO in javascript. An Javascript 1 June 8th, 2003 08:34 AM



All times are GMT -4. The time now is 11:44 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.