I have a form that submitted by javascript via a button click. It was an ajax submit to an iframe. Everything was working fine until I changed the tag from ‘form’ to ‘cfform’. From what I understand, this shouldn’t cause a problem, but, obviously, I am mistaken. I need cfform because I want to use a cftextarea with the richtext attribute. With the tag as cfform, upon a submit the iframe displays a 404 which completely boggles my mind. Here is my code.
coldfusion:
//In my code, the lines are not broken like this
<cfform action="<cfif IsDefined('URL.itemID')>
actionEditItem.cfm
<cfelse>
actionAddItem.cfm</cfif>"
method="post" target="my_iframe" name="itemForm" enctype="multipart/form-data">
//the button that submits the form, again, lines aren't broken
<input type="button" <cfif IsDefined('URL.itemID')>
value='Update Item' onClick='javascript:updateItem();'
<cfelse>
value='Add Item' onClick='javascript:validateItem();'
</cfif>>
javascript:
itemForm.submit();
Any ideas? Thanks!
You can’t put a CFIF inside the
cfformtag like you are doing. It’s trying to render thecfformand breaking. This is not an issue with a regular html form. For this instance, I would set a temp var and use that within theactionattribute.Alternatively, if you don’t want to use a temp var, you can use
IIF.