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
  #1 (permalink)  
Old May 19th, 2005, 05: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 Javascript confirm box with just an 'OK' button

How can i have a Javascript confirm box with just an 'OK' button and now 'Cancel' button:

Code:
<script language="javascript" type="text/javascript">
//////////////////////////////////////////////////////////////
// Check to see if there is a value inside the                 //
// contract id textbox if there isnt then output a message  //
//////////////////////////////////////////////////////////////

function checkFields() {
missinginfo = "";
if (document.form.contract_id.value == "") {
missinginfo += "\n     -  Contract ID";
}

if (missinginfo != "") {
missinginfo = "Please Enter the Contract ID"
document.form.contract_id.focus();
confirm(missinginfo);
return false;
}
else return true;
}


</script>
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
__________________
_______________________
Ayrshire Minis - a Mini E-Community
http://www.ayrshireminis.com
http://www.crmpicco.co.uk
Reply With Quote
  #2 (permalink)  
Old May 19th, 2005, 08:08 AM
Friend of Wrox
 
Join Date: Jul 2003
Location: , , United Kingdom.
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

alert() only has an OK button

Reply With Quote
  #3 (permalink)  
Old May 19th, 2005, 08:42 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

i was just looking for a Confirm box because the Alert looked more like an error. is it possible to specify the buttons in a confirm box?

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
  #4 (permalink)  
Old May 19th, 2005, 08:47 AM
Friend of Wrox
 
Join Date: Jul 2003
Location: , , United Kingdom.
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

afraid not. you'll need to create something custom.

Reply With Quote
  #5 (permalink)  
Old May 20th, 2005, 04:05 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

is that JavaScript? Have you got any code that could do this or get me started?

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
  #6 (permalink)  
Old May 20th, 2005, 06:31 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

how can this be done

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
  #7 (permalink)  
Old May 24th, 2005, 03:49 AM
Friend of Wrox
 
Join Date: Jul 2003
Location: , , United Kingdom.
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Sorry Picco, been away a couple of days...

You could do this a number of ways, depending on your target audience. If you only cared about IE, you could use showModalDialog() and have a single button on you dialogue. For a more generic solution you could use a new window / absolutely positioned div etc with the button on it.

Afraid I don't have the code handy, but there a quite a few articles out there on creating modal windows.

HTH,

Chris
Reply With Quote
  #8 (permalink)  
Old May 24th, 2005, 04:35 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, thanks

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
  #9 (permalink)  
Old May 24th, 2005, 04:42 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

i have this code, but it gives me a Javascript error:
Code:
<html>
   <head>
      <script language="jscript">
         var gobjXDocument = null;

         function Initialize()
         {
            // Save a reference to the XDocument object.
            if (typeof window.dialogArguments == "object")
            gobjXDocument = window.dialogArguments;
         }
      </script>

      <title>A Simple Custom Dialog Box</title>
   </head>

   <body style="BACKGROUND-COLOR: window" onLoad="Initialize()">
      <strong>Click one of the following buttons:</strong>
      <br/>
      <br/>
      <div id="divButtons" tyle="align:center">

         <input id="btnShowAlert" style="WIDTH: 106px; HEIGHT: 24px" 
         onclick='gobjXDocument.UI.Alert(gobjXDocument.DOM.xml);' 
         type="button" size="21" value="Show Alert"></input>

         <input id="btnCancel" style="WIDTH: 106px; HEIGHT: 24px" 
            onclick="window.close();" type="button" size="21" 
            value="Cancel"></input>
      </div>
   </body>
</html>
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
  #10 (permalink)  
Old May 24th, 2005, 05:01 AM
Friend of Wrox
 
Join Date: Jul 2003
Location: , , United Kingdom.
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

What is XDocument? Are you passing it to this page as an argument in showModalDialog()?

Cheers,

Chris

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 19th, 2007 11:48 PM
Javascript Confirm Message box itHighway Javascript How-To 5 September 25th, 2006 02:51 AM
Confirm Button after update fixitman Access 2 April 12th, 2004 03:28 PM
Confirm alert box - need help, Please! larry HTML Code Clinic 1 January 25th, 2004 01:07 AM
how to default confirm box to NO in javascript. An Javascript 1 June 8th, 2003 07:34 AM



All times are GMT -4. The time now is 02:26 AM.


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