Search code examples
xmlcoldfusioninputcoldfusion-8

what the correct synatax to use XMLFormat() in Coldfusion with input fields?


I'm sitting on a from trying the Coldfuion XMLFormat() function.

However if I do this:

<form name="sample" action="#cgi.script_name#" method="post">
    <input name="test" value="#XMLFormat( form.test )#" type="text" tabindex="1" />
</form>

I'm just getting CF-erors, that element test is undefined. What am I doing wrong?

Thanks for input!


Solution

  • You need to check if form.test exists:

    <form name="sample" action="#cgi.script_name#" method="post">
      <input name="test" value="<CFIF structkeyexists(form,"test")>#XMLFormat( form.test )#</CFIF>" type="text" tabindex="1" />
    </form>