Note: I did not modify the code that will show this attribute when you right
click and choose "Edit Current Tag". I have not yet learned how to do this.

-----Original Message-----
From: John Stanley 
Sent: Wednesday, June 01, 2005 11:16 AM
To: '[email protected]'
Subject: [plum] CF_DisplayCheckBox Custom Tag Modification


All,
        I needed the ability for the DisplayCheckbox tag to handle click
actions separate than what happens during form submission. Basically what I
needed to happen was if the user clicks the checkbox, the page gets reloaded
passing in a variable that then executes some CF code.

        I didn't find any way of doing this short of just using
CF_DisplayExtraFormContent and just hard coding the stuff I needed, but I
can see a need in our system to handle this in more than one area, and there
are too many benefits to using the Plum custom tags to really have that be a
viable option.

        So I thought someone on the list might find this useful.

        I have tested this in FireFox and IE. I guess browser compatibility
will really be determined by what JS you decide to call in the event
handler.

        If you find any problems let me know.


Change:
        Added onClick attribute.

Tag Call:
        <cf_DisplayCheckBox column="autopath" label="Autopath"
checkedValue="1" uncheckedValue="0"
onClick="if(this.checked){document.location='#Application.absoluteUrlRoot#/a
dmin/Menu/MenuEditForm.cfm?menu_id=#menu_id#&autopath=true'}">

        Note: you can have the onClick attribute send a js function, if I
did it in this case I would need to send through the
application.absoluteurlroot through as well as either the object or the
object.checked property.

Tag Code:
        <cfsetting enablecfoutputonly="Yes">
<!---
This code is Copyright (c) 2003 by Productivity Enhancement, Inc.  
All Rights Reserved.

Use of this software is persuant to the terms of the End User License
Agreement
at http://www.productivityenhancement.com/plum/SoftwareLicenseAgreement.cfm

Development Team: 
Adam Churvis ([EMAIL PROTECTED])
David Churvis ([EMAIL PROTECTED])
--->

<cfparam name="Attributes.column" type="string">

<cfparam name="Attributes.label" type="string"
default="#Attributes.column#">
<cfparam name="Attributes.checkedValue" type="string" default="1">
<cfparam name="Attributes.uncheckedValue" type="string" default="0">
<cfparam name="Attributes.default" type="string"
default="#Attributes.uncheckedValue#">
<cfparam name="Attributes.onClick" type="string" default="">

<cfif ThisTag.ExecutionMode EQ "Start">

<!--- Get the parent data from the form tag (whether it is an add or an edit
form) --->
<cfif ListFind(GetBaseTagList(), "CF_DISPLAYADDFORM")>
        <cfset parentData = GetBaseTagData("CF_DISPLAYADDFORM")>
<cfelseif ListFind(GetBaseTagList(), "CF_DISPLAYEDITFORM")>
        <cfset parentData = GetBaseTagData("CF_DISPLAYEDITFORM")>
</cfif>

<!--- If the form tag is preparing data, use CFASSOCIATE to pass the current
tag's attributes --->
<cfif parentData.Attributes.formStatus EQ "Preparing">

        <cfif ListFind(GetBaseTagList(), "CF_DISPLAYADDFORM") GT 0>
                <cfassociate basetag="CF_DISPLAYADDFORM"
datacollection="fields">
        <cfelseif ListFind(GetBaseTagList(), "CF_DISPLAYEDITFORM") GT 0>
                <cfassociate basetag="CF_DISPLAYEDITFORM"
datacollection="fields">
        </cfif>

<!--- If the form tag is executing its child field tags, put out the table
row and checkbox control --->
<cfelseif parentData.Attributes.formStatus EQ "Executing">
        
        <cfif IsDefined("ParentData.currentRecord")>
                <cfparam name="Form[Attributes.column]"
default="#parentData.currentRecord[Application.DatabaseBlocks.GetSafeColumnA
lias(parentData.Attributes.table, Attributes.column)][1]#">
        <cfelse>
                <cfparam name="Form[Attributes.column]"
default="#Attributes.default#">
        </cfif>
        
        <cfoutput>
        <tr>
                <td class="fieldlabel">&nbsp;</td>
                <td>
                        <label for="checkbox#Attributes.column#"><input
id="checkbox#Attributes.column#" type="checkbox" name="#Attributes.column#"
value="#Attributes.checkedValue#" <cfif Form[Attributes.column] EQ
Attributes.checkedValue> checked</cfif> </cfoutput>
                        <cfloop collection="#Attributes#"
item="currentAttribute">
                                <cfif NOT
ListFindNoCase("column,label,checkedValue,uncheckedValue,default",
currentAttribute)>
                                        <cfif currentAttribute is "ONCLICK">
        
<cfoutput>onClick="#Attributes[currentAttribute]#"</cfoutput>
                                        <cfelse>
        
<cfoutput>#currentAttribute#="#Attributes[currentAttribute]#" </cfoutput>

                                        </cfif>
                                </cfif>
                        </cfloop>
                        <cfoutput>>#Attributes.label#</label>
                </td>
        </tr>
        </cfoutput>

</cfif>

</cfif>
<cfsetting enablecfoutputonly="No">
        


John Stanley
Web Application Developer
Active Aero Group
http://www.activeaero.com
734-547-7200 office



**********************************************************************
You can subscribe to and unsubscribe from lists, and you can change
your subscriptions between normal and digest modes here:

http://www.productivityenhancement.com/support/DiscussionListsForm.cfm
**********************************************************************

**********************************************************************
You can subscribe to and unsubscribe from lists, and you can change
your subscriptions between normal and digest modes here:

http://www.productivityenhancement.com/support/DiscussionListsForm.cfm
**********************************************************************

Reply via email to