msgbartop
msgbarbottom

03 Jun 08 Creating Custom Alert for ColdFusion’s Flash Form

Recently I was asked to create a flash form using Adobe ColdFusion 7 cfform tag and it needed to have an alert popup before the validation took place.  Here is the code that I used in making the alert happen.  I am not going to go into to much detail with the code as I have added comments into the script for better understanding.

ActionScript used:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<!--- ActionScript for Flash Form --->
<cfsavecontent variable="showAlert">
	var clickHandler = function (event){
		if(event.detail == mx.controls.Alert.YES){
			// submit the form
			_root.submitForm();
 
		}
	}
 
	// set buttons for alert
	mx.controls.Alert.buttonWidth = 100;
 
	// create Alert
	var myAlert = mx.controls.Alert.show("Once you have posted this Idea you will not be able to modify it.\n\nAre you sure?","Idea Pre-Post Warning",
	mx.controls.Alert.YES | mx.controls.Alert.CANCEL, this, clickHandler);
 
	// Change the size
	//myAlert.width = 330;
	//myAlert.height = 180;
 
	//change this alert's style only
	myAlert.setStyle("panelBorderStyle","default");
	//myAlert.setStyle("cornerRadius","12");
</cfsavecontent>

CFML code used:

1
2
3
4
5
6
7
<cfform id="ideaForm" method="post" action="#" skin="haloorange" height="400" width="100%" format="flash" name="ideaForm">
 
	<cfformgroup style="horizontalalign: right" type="horizontal">
		<!--- button activates alert --->
		<cfinput id="btnSubmit" onclick="#showAlert#" name="btnSubmit" type="Button" value="Save" />
	</cfformgroup>
</cfform>

That’s it. If you need to know more about what is taking place here please post a comment and I will reply as soon as I can.