문제

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.

도움이 되었습니까?

해결책

<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#" />
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top