Groups | Blog | Home
all groups > coldfusion flash integration > april 2007 >

coldfusion flash integration : cfformitem type="script": How to set hidden field's value?



cf_dev2
4/19/2007 10:18:29 PM
I have a simple test form that contains a cftree and a few input/hidden fields.
Whenever a tree node is selected, I want to change the values of input/hidden
fields to whatever node was selected. Pretty simple, but I can't figure out
how to change the values of the hidden fields.

Load the form, select "ItemA" and click submit. The values of the hidden form
fields don't change. They're always "not set". What is the correct syntax for
changing a hidden field's value?




<cfdump var="#form#">
<cfform name="myForm" format="flash">
<cfformitem type="script">
function test(theValue:String):Void {
var valueString:String = theValue.toString();
title.text = "title = "+ valueString;
description.text = "description = "+ valueString;
myForm.theType.text = "theType = "+ valueString;
myForm.theID.text = "theID = "+ valueString;
}
</cfformitem>

<cftree name="itemTree"
onchange="test(itemTree.selectedNode.getProperty('data').value)">
<cftreeitem display="ItemA" value="ItemA" parent="" expand="no" />
<cftreeitem display="ItemB" value="ItemB" parent="ItemA" expand="no" />
<cftreeitem display="ItemC" value="ItemC" parent="ItemB" expand="no" />
<cftreeitem display="ItemD" value="ItemD" parent="ItemB" expand="no" />
</cftree>

<cfformgroup type="panel" label="Add / Edit">
<cfformgroup type="horizontal">
<cfformitem type="text" style="fontWeight:bold;"
width="80">Title:</cfformitem>
<cfinput name="title" type="text" width="200" value=" " />
</cfformgroup>
<cfformgroup type="horizontal">
<cfformitem type="text" style="fontWeight:bold;"
width="80">Description:</cfformitem>
<cftextarea name="description" type="text" height="100" />
</cfformgroup>
<cfinput type="hidden" name="theType" value="not set" />
<cfinput type="hidden" name="theID" value="not set" />
<cfinput type="submit" name="submitButton" value="Submit">
</cfformgroup>
</cfform>
The ScareCrow
4/19/2007 11:05:30 PM
The correct syntax is

myForm.theID = "theID = "+ valueString;

Ken
cf_dev2
4/20/2007 1:12:02 AM
That was it. Thanks! Weird that there's a different syntax for hidden fields.

Do you know if there any online references or documentation for scripting?
I've been using snippets from tutorials and trying to figure out the syntax
from flex documentation.


The ScareCrow
4/22/2007 3:53:11 AM
You will need to use a combination of resources.


1. CF Documentation

http://livedocs.adobe.com/coldfusion/7/htmldocs/wwhelp/wwhimpl/common/html/wwhel
p.htm?context=ColdFusion_Documentation&file=part_dev.htm

2. Flash Documentation

3. Flex Documentation

Ken
cf_dev2
4/26/2007 12:00:00 AM
Thanks Ken, that helped. With the updated CF help files and Flash
documentation its starting to make a little more sense.

On a humorous note, I have to say it feels a little like the instructions are
written in Swahili and I'm using an English-to-Russian dictionary and then a
Russian-to-Swahili dictionary to read them ;-)

The ScareCrow
4/26/2007 11:27:25 PM
So that's my problem, someone stole my Russian-to-Swahili dictionary

cf_dev2
4/27/2007 4:05:49 PM
AddThis Social Bookmark Button