Adobe Dreamweaver Forums



Last 10 THreads :         whats the problem with this page (Last Post : hakand83 - Replies : 10 - Views : 11 )           »          Center textfield inside movie clip (Last Post : granddemon - Replies : 3 - Views : 4 )           »          event calendar dhtml or jsp (Last Post : John Waller - Replies : 1 - Views : 2 )           »          HTML code to a XML document (Last Post : sebast73 - Replies : 0 - Views : 1 )           »          File upload problems (Last Post : Nedward - Replies : 1 - Views : 2 )           »          Make DW use JS code-coloring instead of PHP (Last Post : danilocelic AdobeCommunityExpert - Replies : 1 - Views : 2 )           »          Spry:region does not validate on w3.org (Last Post : V1 Fusion - Replies : 3 - Views : 4 )           »          Properties options not showing properly (Last Post : MadobeM - Replies : 6 - Views : 7 )           »          my email address has been hijacked! (Last Post : Dooza - Replies : 6 - Views : 7 )           »          ASP pages do not display (Last Post : Dooza - Replies : 17 - Views : 18 )           »         


Home Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
User Info Statistics
Go Back   Adobe Dreamweaver Forums > Macromedia Software > Cold Fusion > Flash Intergration
 
Tags:



Reply
  #1 (permalink)  
Old 11-04-2008, 04:24 PM
Count Zero
 
Posts: n/a
Diggs:
Default 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>



Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 11-11-2008, 03:35 AM
-==cfSearching==-
 
Posts: n/a
Diggs:
Default Re: How do I use the form checkbox value?

> HOW DO I TEST IF A CHECKBOX HAS BEEN SELECTED?
> // ALSO: is there a way to display the various values/objects? For

instance, JS has alert();

Yes, from an html perspective checkboxes confusingly use the
http://livedocs.adobe.com/flex/15/as.../CheckBox.html 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>

> HOW DO I MAKE USE OF THE CHECKBOX VALUE TO ADD TO MY ACCUMULATOR?


That is bit trickier. I am not an flash guru. But as I understand it
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

Reply With Quote
  #3 (permalink)  
Old 11-17-2008, 08:24 PM
Count Zero
 
Posts: n/a
Diggs:
Default 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";



Reply With Quote


  #4 (permalink)  
Old Today, 05:13 PM
-==cfSearching==-
 
Posts: n/a
Diggs:
Default Re: How do I use the form checkbox value?

> HOW DO I TEST IF A CHECKBOX HAS BEEN SELECTED?
> // ALSO: is there a way to display the various values/objects? For

instance, JS has alert();

Yes, from an html perspective checkboxes confusingly use the
http://livedocs.adobe.com/flex/15/as.../CheckBox.html 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>

> HOW DO I MAKE USE OF THE CHECKBOX VALUE TO ADD TO MY ACCUMULATOR?


That is bit trickier. I am not an flash guru. But as I understand it
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

Reply With Quote
  #5 (permalink)  
Old Today, 05:13 PM
Count Zero
 
Posts: n/a
Diggs:
Default 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";



Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
All times are GMT. The time now is 05:36 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Cheap Car Insurance - Compare Motor Insurance
Endsleigh Car Insurance Natwest Car Insurance
More Than Car Insurance Norwich Union Car Insurance
Prudential Car Insurance Zurich Car Insurance
Inactive Reminders By Mished.co.uk