I have 2 cffunctions, one javascript function to call those 2, a checkbox to
call javascript function onClick. I put a javascript between checkbox and
cffunctions because I do not know how to call cffunction onClick. The
problem is: everytime the screen refreshes, 2 cffunctions are called instead
of 1 at a time depending on the checkbox checked or not. Any idea would be
much appreciated.

 

<cfdump var="#session.finaltotal#">

<cffunction name="increasetotal" output="no" hint="update total">

            <cfargument name="finaltotal" type="array">

            <cfset temp1 = session.finaltotal[1] + 20>

            <cfset ArraySet( ARGUMENTS.finaltotal,1,1, temp1 ) />

            <cfreturn ARGUMENTS.finaltotal[1]>

</cffunction>

<cffunction name="decreasetotal" output="no" hint="update total">

            <cfargument name="finaltotal" type="array">

            <cfset temp2 = ARGUMENTS.finaltotal[1] - 10>

            <cfset ArraySet( ARGUMENTS.finaltotal,1,1, temp2 ) />

            <cfreturn ARGUMENTS.finaltotal[1]>

</cffunction>

<script>

<cfoutput>

function hello(checkboxes, index)

{

            alert(<cfoutput>#session.finaltotal[1]#</cfoutput>);

            checkbox = checkboxes[index];

            if(!checkbox) {

                        checkbox = checkboxes;

            }

            var temp = 0;

            if(checkbox.checked) {

                        temp = #increasetotal(session.finaltotal)#;

                        alert("checked");

            } else if (!checkbox.checked){

                        temp = #decreasetotal(session.finaltotal)#;

                        alert("unchecked");

            }

            alert(temp);

            window.location.reload();

}

</cfoutput>

</script>

 

<cfoutput>

<cfform NAME="listForm" METHOD="POST"

ACTION="http://www.annistonmorningrotary.org/temp/confirmpremium.cfm";>

<table border=1>

<tr><td><cfinput type="checkbox" name="chosenSite" value="1"
onclick="javascript:hello(document.listForm.chosenSite, 0);"/>

</table>

</cfform>

</cfoutput>

 

(by the way, session variables have been defined on previous page)




~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:254993
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to