473,404 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

How can I create a confirmation box in ColdFusion?

Haitashi
I had the following code that would create a javascript confirmation page. This code lived inside a form which wouldn't submit until the user clicked the Ok button.

Expand|Select|Wrap|Line Numbers
  1. <input type="image" onclick="return confirm('You will not be able to change your answers if you submit now.\nAre you sure you want to submit this test?');" name="SubmitTestButton" src="images/submit_test.jpg" value="Submit Test" class="submit_test_button" />
I've bee trying to achieve the same effect using CFWINDOW. Only, once the window comes up the form automatically submits.

Current code:
Expand|Select|Wrap|Line Numbers
  1.         <form name="TestForm" [...]>
  2.  [OTHER CODE]
  3.  
  4.                 <p><input type="image" onclick="ColdFusion.Window.show('submitTest')" name="SubmitTestButton" src="images/submit_test.jpg" value="Submit Test" class="submit_test_button" /></p>
  5.             </cfif>
  6.         </form>
  7.  
  8.         <cfwindow name="submitTest"
  9.             center="true"
  10.             closable="true"
  11.             draggable="false"
  12.             height="200"
  13.             width="200"
  14.             initShow="false"
  15.             modal="true"
  16.             refreshOnShow="false"
  17.             resizable="false">
  18.                     <cfoutput>
  19.                         <p>You will not be able to change your answers if you submit now. </p><p>Are you sure you want to submit this test?</p>
  20.                         <input type="image" name="SubmitTestButton" src="images/submit_test.jpg" value="Yes, Please Sumbit" class="submit_test_button" /></p>
  21.  
  22.                     </cfoutput>
  23.         </cfwindow>
I've been trying to figure out a way to create a coldfusion confirmation box, essentially. Any help or direction will be appreciated. I will post back the final code for reference.
May 2 '08 #1

✓ answered by Haitashi

I am using cfwindow. =) This is the cfwindow code that I have in place of what is written at line 23 above.

Expand|Select|Wrap|Line Numbers
  1.          <cfajaximport cssSrc="styles/cfskins/" />        
  2.         <cfwindow name="cfwinconfirm"
  3.             center="true"
  4.             closable="true"
  5.             draggable="false"
  6.             height="200"
  7.             width="380"
  8.             initShow="false"
  9.             modal="true"
  10.             resizable="false">
  11.                 <cfoutput>
  12.                     <span class="test_confirmation_window">
  13.                     <p>    You will not be able to change your answers if you submit now. </p><p>Are you sure you want to submit this test?</p>
  14.                     <p>    <input type="image" onclick="hideAndSubmit('cfwinconfirm','TestForm'); return false;" name="confirmSubmit"  src="images/submit_button.gif" class="confirmation_test_button" />
  15.                         <input type="image" onclick="hideCfWindowConfirm(); return false;" name="cancel" src="images/cancel_button.gif" class="confirmation_test_button" />
  16.                     </p>
  17.                     </span>
  18.                 </cfoutput>
  19.         </cfwindow>

7 9786
acoder
16,027 Expert Mod 8TB
If it's just an image button, why does it submit?

You need to return true or false to control the form submission, but cfwindow doesn't return anything, but what you can do is use the Coldfusion.Window.onHide function to define a function to run when the window is "closed".
May 3 '08 #2
What you're saying makes sense but what if after clicking submit, they get that box and they decide they don't want to submit after all - if they close the window then it would still submit, wouldn't it?
May 5 '08 #3
acoder
16,027 Expert Mod 8TB
Not quite. If, for example, you return false when calling from onsubmit, the form will not submit.
May 5 '08 #4
Ok. I did something based off what you said. I did implement some javascript, though.

Expand|Select|Wrap|Line Numbers
  1. <form name="ParentForm" id="ParentForm" action="action.cfm" method="post">
  2.  
  3.     <input type="hidden" name="TestFormField" value="booyah" />
  4.     <input type="submit" value="Submit the Parent Form" onclick="showCfWindowConfirm(); return false;" />
  5.  
  6. </form>
  7.  
  8. <script type="text/javascript">
  9.     function showCfWindowConfirm() {
  10.         ColdFusion.Window.show('cfwinconfirm');
  11.     }
  12.  
  13.     function hideCfWindowConfirm() {
  14.         ColdFusion.Window.hide('cfwinconfirm')
  15.     }
  16.  
  17.     function hideAndSubmit(cfwindowname,formID) {
  18.         ColdFusion.Window.hide(cfwindowname)
  19.         document.getElementById(formID).submit();
  20.     }
  21. </script>
  22.  
  23. <cfwindow initShow="false" title="Confirm" name="cfwinconfirm" modal="true" center="true" source="confirm.cfm" width="300" height="150"/>
and in confirm.cfm:

Expand|Select|Wrap|Line Numbers
  1. <a href="" onclick="hideAndSubmit('cfwinconfirm','ParentForm'); return false;">Confirm</a>
  2. <a href="" onclick="hideCfWindowConfirm(); return false;">Cancel</a>
Note: this is the the skeleton of what I did just for demonstration purposes. It does not reflect how the scripts and files were placed in my actual application.

As always, I really appreciate the help!
May 5 '08 #5
acoder
16,027 Expert Mod 8TB
That seems about right.

If you wanted to really get fancy, you could try replacing the confirm dialog with a cfwindow dialog, though you may need to extend it to return values.
May 6 '08 #6
I am using cfwindow. =) This is the cfwindow code that I have in place of what is written at line 23 above.

Expand|Select|Wrap|Line Numbers
  1.          <cfajaximport cssSrc="styles/cfskins/" />        
  2.         <cfwindow name="cfwinconfirm"
  3.             center="true"
  4.             closable="true"
  5.             draggable="false"
  6.             height="200"
  7.             width="380"
  8.             initShow="false"
  9.             modal="true"
  10.             resizable="false">
  11.                 <cfoutput>
  12.                     <span class="test_confirmation_window">
  13.                     <p>    You will not be able to change your answers if you submit now. </p><p>Are you sure you want to submit this test?</p>
  14.                     <p>    <input type="image" onclick="hideAndSubmit('cfwinconfirm','TestForm'); return false;" name="confirmSubmit"  src="images/submit_button.gif" class="confirmation_test_button" />
  15.                         <input type="image" onclick="hideCfWindowConfirm(); return false;" name="cancel" src="images/cancel_button.gif" class="confirmation_test_button" />
  16.                     </p>
  17.                     </span>
  18.                 </cfoutput>
  19.         </cfwindow>
May 6 '08 #7
acoder
16,027 Expert Mod 8TB
Nice. Thanks for posting and glad to see that you've got a working solution.
May 6 '08 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

60
by: English Teacher | last post by:
Which would be more useful to learn, PHP or COLDFUSION? I know Coldfusion is popular in the work force. Is PHP? Thanks!
16
by: worzel | last post by:
is python more popular than coldfusion? I realsie that is a very general question as one thing does not directly relate to the other. My issue is that I am ditching coldfusion due to there being...
4
by: William Fields | last post by:
Hello, I'm trying to find out more information about ColdFusion and could not find what I'm looking for on Macromedia's website. My question has more to do with what ColdFusion is and how web...
0
by: asnyder131 | last post by:
I'm a newby here as well as to mysql and coldfusion. I'm a business owner who had previously designed my own relational database system for my company (smartware) and used it sucessfully for many...
0
acoder
by: acoder | last post by:
This page will link to a number of tutorials. Coldfusion Language Coldfusion Variables Using Coldfusion Variables Coldfusion Image Gallery How to upload a file in Coldfusion Watch this...
3
acoder
by: acoder | last post by:
How to Upload a File in Coldfusion Use the cffile tag for uploading files to the server. Note that allowing people to upload files is fraught with danger and only trusted users should be...
7
acoder
by: acoder | last post by:
This page will link to a number of tutorials. Coldfusion Language Coldfusion Variables Using Coldfusion Variables Coldfusion Image Gallery How to upload a file in Coldfusion How to send...
2
by: quest007 | last post by:
Hi! I have configured IIS for coldfusion and when I access my coldfusion site through localhost, the pages are served as required. But if i ty to access it from a remote machine by specifying the IP...
106
by: bonneylake | last post by:
Hey Everyone, Well i don't know if my question should be in javascript/ajax or coldfusion, i figure this is more of a coldfusion question. But if this is in the wrong section let me know an all...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.