lonnyo
asked on
Javascript with ColdFusion form using OnClick
I have a form that is used in a Content Management System to update a webpage. The first button is a preview button, so the user can see what the page looks like before submitting it to the database. The second button submits the form information to the database so the changes are live on the site.
On submission of the update button, I want to present a message that warns the user it will permanently update the website and cannot be undone.
I want an pop up box to appear with the option to continue or cancel. I have done this before, but not combined with other actions within an OnClick event.
Here is the code I have right now:
Thanks for the help.
On submission of the update button, I want to present a message that warns the user it will permanently update the website and cannot be undone.
I want an pop up box to appear with the option to continue or cancel. I have done this before, but not combined with other actions within an OnClick event.
Here is the code I have right now:
<cfform class="clear-both" name="formUpdatePreviewContent" action="../#ActionFile#?CategoryID=#CategoryID#&ParentID=#ParentID#" method="post">
<label for="Content">
<cftextarea richtext="true" toolbar="Default" basepath="FCKEditor" name="Content" width="735" height="400">#Content#</cftextarea>
</label>
<cfinput type="hidden" name="ContentID" id="ContentID" value="#ContentID#">
<cfif IsDefined("getContentByCategoryID.ContentID")>
<cfinput type="hidden" name="ArchiveContentID" value="#getContentByCategoryID.ContentID#">
<cfinput type="hidden" name="Label" value="#getContentByCategoryID.Label#">
<cfinput type="hidden" name="DeleteSEOID" value="#getContentByCategoryID.SEOID#">
</cfif>
<cfif IsDefined("Form.CurrentCategoryID")>
<cfinput type="hidden" name="CurrentCategoryID" value="#Form.CurrentCategoryID#">
</cfif>
<p> </p>
<p class="center"><cfinput style="font-size:24px; width:200px;" type="submit" name="Preview" onclick="this.form.target='_blank';return true;" value="Preview"></p>
<p class="center"><cfinput cfinput style="font-size:12px;" type="submit" name="SubmitPageUpdate" onclick="formUpdatePreviewContent.action='edit_content.cfm'; formUpdatePreviewContent.target='_self'; return true;" value="Submit Page Update"></p>
</cfform>
Thanks for the help.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
> I was using that name in a CFIF statement to perform the database update.
Oh, yeah. That's because I changed it from a submit button to a regular one. Because the final code's a little simpler. But you could you could probably change it back and <form onSubmit="return ..." instead of calling the function onClick.
Oh, yeah. That's because I changed it from a submit button to a regular one. Because the final code's a little simpler. But you could you could probably change it back and <form onSubmit="return ..." instead of calling the function onClick.
ASKER
I managed to trick it by adding a hidden form variable with that name (changed the submit button so I would not have duplicate names).
It is now working like it should.
Thank you for the help (and the clean code).