Ask a Question related to Coldfusion Flash Integration, Design and Development.
-
Count Zero #1
How do I use the form checkbox value?
I'm creating a form that has multiple checkboxes. I want to use ActionScript to
update a text box/area with the values each checkbox as the checkbox is
selected. Any ideas on how I might do that?
SAMPLE CODE ATTACHED.
<cfsavecontent variable="calcCost">
var accumulator = 0;
var ch1 = chkBox_test1;
var ch2 = chkBox_test2;
var ch3 = chkBox_test3;
var ch4 = chkBox_test4;
var ch5 = chkBox_test5;
AND NOW HERE IS THE PROBLEM - HOW DO I TEST IF A CHECKBOX HAS BEEN SELECTED?
HOW DO I MAKE USE OF THE CHECKBOX VALUE TO ADD TO MY ACCUMULATOR?
/************************************************** ***************
JavaScript lets me do something on the order of
if( form.chkBox_test1.checked == true )
{
if( form.chkBox_test1.value <> 0 )
accumulator += form.chkBox_test1.value;
}
else
{
do something else..........
}
************************************************** ***************/
// How do I do the same thing in ColdFusion ActionScript?
Cost.text = accumulator;
// ALSO: is there a way to display the various values/objects? For instance,
JS has alert();
</cfsavecontent>
<cfform name="myForm" action="my url whatever" format="flash" method="post"
width="510" height="1200" skin="halogreen" preloader="true">
<cfinput name="Cost" label="Your cost will be: " type="text" size="10"
value="00.00">
<cfformgroup type="tabnavigator">
<cfformgroup type="page" label="1. Simple Test - Cost Selector">
<cfformitem type="text">Please select the options you would
like.</cfformitem>
<cfformgroup type="hdividedbox">
<cfformgroup type="vbox">
<cfinput name="chkBox_test1" type="checkbox" label="Option 1 $1.00"
value="1" onClick="#calcCost#">
<cfinput name="chkBox_test2" type="checkbox" label="Option 2 $2.00"
value="2" onClick="#calcCost#">
<cfinput name="chkBox_test3" type="checkbox" label="Option 3 $3.00"
value="3" onClick="#calcCost#">
<cfinput name="chkBox_test4" type="checkbox" label="Option 4 $4.00"
value="4" onClick="#calcCost#">
<cfinput name="chkBox_test5" type="checkbox" label="Option 5 $5.00"
value="5" onClick="#calcCost#">
</cfformgroup>
</cfformgroup>
</cfformgroup>
</cfformgroup>
</cfform>
Count Zero Guest
-
CheckBox required on form?
I have a form, and we need to have a checkbox that the user is required to check. Basically saying they read the disclaimer. Is there a way to... -
Flash Form & Checkbox
I'm having trouble changing this listbox code to checkboxes instead. Can you help? <cfselect name="binderyID" label = "Bindery Type"... -
Checkbox Set To OFF Not In Request.Form
When using checkboxes on a form, if you uncheck them, the unchecked name/value pair in the Request.Form collection doesn't show up. It only shows... -
Form CheckBox question
Hello, I have this in my form.... the checkUnCheck(this); will uncheck values 1,2,3 if None is chosen... Now when I submit this form, the output... -
Yes/No checkbox in the form
I have a field called action in a table, to check if something requires action the user must check the box. The field in the table is defined as a... -
-==cfSearching==- #2
Re: How do I use the form checkbox value?
> HOW DO I TEST IF A CHECKBOX HAS BEEN SELECTED?
instance, JS has alert();> // ALSO: is there a way to display the various values/objects? For
Yes, from an html perspective checkboxes confusingly use the
[url]http://livedocs.adobe.com/flex/15/asdocs_en/mx/controls/CheckBox.html[/url] property,
rather than checked. However, actionscript does have alerts. The simplest form
is very similar to a javascript alert.
<!--- displays a message only if the first checkbox was checked --->
<cfsavecontent variable="calcCostAmount">
if (chkBox_test1.selected) {
alert("chkBox_test1 is checked");
}
</cfsavecontent>
That is bit trickier. I am not an flash guru. But as I understand it> HOW DO I MAKE USE OF THE CHECKBOX VALUE TO ADD TO MY ACCUMULATOR?
checkboxes do not use values like their html counterparts. The checkbox value
is either "true" if checked or "false" if unchecked. There may be better
methods, but you might try storing the values "1,2,3,...5" in hidden fields.
Then use a loop to total them. Assuming onClick is the correct event to use
here ..
HTH
-==cfSearching==- Guest
-
Count Zero #3
Re: How do I use the form checkbox value?
A form is created using cfform format=flash.
A cfinput text box is created and flagged as not visible.
The "invisible" input value is set after a cfoutput query="xxxx"
is completed.
Since I'm using the query to do double duty, I have a group set.
My "second" group is the one on which I wanted the check boxes to
be created dynamically.
I set a counter, and kept track of when a check box was created.
The value of the counter was eventually set as the value of my
first "invisible" text box.
Here's the code:
<cfformgroup type="horizontal" height="1" visible="no">
<cfif #BoxCount# GT 0>
<cfoutput><cfinput name="BoxQty" type="text" value="#BoxCount#"
visible="no" size="3"></cfoutput>
</cfif>
</cfformgroup>
Each check box was given a unique name, text + counter.
ex. camp#BoxCount#
A corresponding "invisible" text box was created:
ex. cost#BoxCount#
This way I can test if the check box "value" is true/false, and
set a cost accumulator to the proper cost.
My cfsavecontent code looks like this:
// COST TOTAL
var a = Number(BoxQty.text);
var i = 0;
var j = 0;
var u = 0;
var x = 0;
var s = "";
for( i=1; i<=a; i++ )
{
r = "camp"+i;
if( eval(r).value ) // just like the JS eval()
{
// box was checked, i.e. is "true"
s = "cost"+i;
j = Number(eval(s).text);
if( j > 0 ) x = x + j; // add to the total accumulator
}
}
//campCost is the cfinput text box used to display the total cost.
campCost.text = 0;
if( x != 0 )
campCost.text = "$" + x + ".00";
Count Zero Guest



Reply With Quote

