Skip navigation
Currently Being Moderated

cfmessagebox

Aug 19, 2012 2:01 PM

I am trying to use cfmessage box to confirm prior to deleting a record.  I have a delete button that I am diplaying the fessage box using onclick.  The problem I am having is the cfmessagebox pop's up, but the record gets deleted anyway and the cfmessagebox goes away.  Basically, the form is getting submitted regardless.  I am thinking I am doing something wrong here, but can someone point me in the right direction.  Below is come code snippets:

 

cfmessagebox code:

<cfmessagebox type="confirm" name="confirmdelete" title="Delete Employee?"

     message="Are you sure you want to delete this employee?"

     buttonType="YesNo" icon="warning" labelYes="Yes" labelNo="No">

 

 

Button code:            

<button type="submit" id="delete_button" name="delete_button" onClick="javascript:ColdFusion.MessageBox.show('confirmdelete');">Del ete</button>

 

I am pretty sure I should change the button type to "button" rather than submit.  Then, use calbackhandler to submit the form.  However, once the form is submitted, I check for which button is pressed using:

<cfif isDefined("form.delete_button")>

I need to submit the form using javascript, then make sure, after the form is submitted, to make sure the above if statement is true.

 

Any ideas on what I am doing wrong?  Or, any better ways to do this?

 
Replies
  • Currently Being Moderated
    Aug 20, 2012 5:35 AM   in reply to wannab0133

    I think you might have answered your own question.  Changing the input from submit to button should resolve the issue.  The submit button is processing the form, regardless of what happens in the cfmessage.  Using JavaScript to submit the form is (IMHO) best.

     

    ^_^

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points