Skip to main content
Participant
July 7, 2006
Answered

Javascript submit() function


Ok, I've been working on this all day and I hoping someone can help me.

The alerts work correctly, but the form never submits. I've tried changing the cfinputs to read submit versus button. When I do that, it blows by the JS alerts and submits the page. I need the alerts to appear BEFORE submitting the page.

<cfform name="LINAdmin" method="post" action="prereqBranch.cfm" format="flash">
<cfformitem type="script">
function submitButton(type) {
if (type == "Transition LIN") {
if (resultsGrid.selectedItem.lin == undefined) {
alert("You must select a LIN to transition.");
return false;
} else {
alert("Before you can mark a LIN for transition, you must complete the following form.");
LINAdmin.Submit();}
}
}
</cfformitem>

<cfformgroup type="horizontal" style="horizontalAlign:center;">
<cfinput type="button" name="branch" value="Transition LIN" onClick="submitButton('Transition LIN')">
<cfinput type="button" name="branch2" value="LIN Remains" onClick="submitButton('LIN Remains')">
</cfformgroup>
</cfform>

THANK YOU!
Jennifer
This topic is closed to new replies. Start a new post to keep the conversation going.
jnoonanCorrect answer
Participant
July 12, 2006
Great! This is what worked. Thanks ScareCrow!

function submitButton() {
var myClickHandler = function (evt){
if (evt.detail == mx.controls.Alert.OK){
_root.submitForm();
}
}

alert("Before you can mark a LIN for transition, you must complete the following form.", "Alert", mx.controls.Alert.OK | mx.controls.Alert.CANCEL, myClickHandler);
}

Great web site for ActionScript help, http://www.asfusion.com.

4 replies

jnoonanAuthorCorrect answer
Participant
July 12, 2006
Great! This is what worked. Thanks ScareCrow!

function submitButton() {
var myClickHandler = function (evt){
if (evt.detail == mx.controls.Alert.OK){
_root.submitForm();
}
}

alert("Before you can mark a LIN for transition, you must complete the following form.", "Alert", mx.controls.Alert.OK | mx.controls.Alert.CANCEL, myClickHandler);
}

Great web site for ActionScript help, http://www.asfusion.com.
Translate
jnoonanAuthor
Participant
July 11, 2006
Thanks Ken, however now it's behaving as if I changed the cfinput to submit versus button. The alert pops up but before you can click OK, the page is submitted.

How can I tell it to submit only if the user clicks the OK button?

Thanks again.
Translate
Inspiring
July 11, 2006
You will need to customize the alert.

An article to do this

Ken
Translate
Inspiring
July 10, 2006
Your actually using actionscript and not javascript.

Thus the code your looking for is

else {
alert("Before you can mark a LIN for transition, you must complete the following form.");
submitForm();}
}

Ken
Translate