I'd like to see a simple template example with SerializeJSON and deserializeJSON posting to the same template and an Array adding each time a pass occurs. I've tried this several times and I keep getting confused by the pass.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
<cfif structKeyExists(form,"jsonArray")>
<cfset arrayData = deserializeJSON(form.jsonArray) />
<cfset arrayAppend(arrayData,form.theText) />
<cfelse>
<cfset arrayData = [] />
</cfif>
<cfoutput>
<form name="input" action="ableto.cfm" method="post">
<input type="hidden" value='#serializeJSON(arrayData)#' name="jsonArray" id="jsonArray" />
Text: <input type="text" value="" name="theText" id="theText" />
<input type="submit" value="Subby" />
</form>
</cfoutput>
<cfdump var="#arrayData#" />
<cfdump var="#form#" />