AL86
AL86

Reputation: 13

use Yes button on cfmessagebox to submit the form

I can get my yesno cfmessagebox to pop up, but no matter what button is clicked, the result is always to submit. I need the yes button to submit, but the no button to take no action. I have tried to mimic a lot of examples, but nothing seems to work. Any help is appreciated. Thanks

<cfform name="DeleteForm" action="SubmitESPDeleteAction.cfm" method="post" style="margin:30px;" >

<cfinput name="DeleteButton" type="text" required="yes" style="color:red;" >

<cfinput name="ConfirmDelete" type="submit" onclick="javascript:ColdFusion.MessageBox.show('CONFIRMTest')" value="Delete Record" >

<cfmessagebox name="CONFIRMTest" type="confirm" message="Are you sure you would like to delete this record?" buttonType="yesno" >

<script lang="javascript" type="text/javascript"  >

    function CONFIRMTest(btn)
        {if (btn == 'yes')
            submit(DeleteForm)
        }


</script>

Upvotes: 0

Views: 1112

Answers (1)

WorkSmarter
WorkSmarter

Reputation: 3808

The problem lies in the JavaScript function conditional statement. Rather than specifying a Boolean conditional, the original code is setting the value of btn to "yes".

Before

    if (btn = 'yes')

After

    if (btn == 'yes')

Upvotes: 1

Related Questions