[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 224
  • Last Modified:

Coldfusion Flash form CF7

Hi i am creating a cf flash form where client has a Permanent Address and Current Address.
if clients both address are same, then i want client to fill out only permanent Address and select a check box which indicates " if address are same" , and by selecting the check box, Current address fields should be filled automatically with all the values entered in Permanent Address.

How can i do that. i will be glad to get any help with examples.

regards
khan
0
khan02
Asked:
khan02
  • 8
  • 7
1 Solution
 
_agx_Commented:
Just use the checkbox's onClick method to update the text field value.  If you have multiple fields, you should create a function for this.
<cfform format="flash">
	<cfinput type="checkbox" name="SameAddresses" label="Addresses are the same" onClick="if(SameAddresses.selected){CurrentAdress.text = PermanentAdress.text;}">
	<cfinput type="text" name="PermanentAdress" label="Permanent Address">
	<cfinput type="text" name="CurrentAdress" label="Current Address">
</cfform>

Open in new window

0
 
khan02Author Commented:
here is my function,

<cfsavecontent variable="addr">
      Con_Address.text = Perm_Address.text;
      Con_City.text = Perm_City.text;
      Con_State.selected = Perm_State.selected;
</cfsavecontent>


Here is the code into form,

<!--- CURRENT MAILING ADDRESS --->
                        <cfformgroup type="panel" label="Current Mailing Address">
                              <cfinput type="text" label="Number and Street" name="Con_Address" value="#qGetData.Con_Address#" required="true" message="" maxlength="255">
                              <cfinput type="text" label="City" name="Con_City" value="#qGetData.Con_City#" required="true" message="" maxlength="255" width="200">
                              <cfselect name="Con_State" label="State" maxlength="255" required="true" message="You must enter a State for Current Mailing Address" width="100">
                                    <option></option>
                                       <cfloop query="qStates">
                                       <option value="#Abbreviation#" <cfif #qGetData.Con_State# is #Abbreviation#>selected</cfif>>#Name#</option>
                                    </cfloop>            
                              </cfselect>
                              
                              <cfselect name="Con_Country" width="200" label="Country" required="true" message="You must a Country for Current Mailing Address">
                                       <option></option>
                                    <cfloop query="qCountries">
                                       <option value="#CountryABB#" <cfif #qGetData.Con_Country# is #CountryAbb#>selected</cfif>>#CountryName#</option>
                                    </cfloop>
                                  </cfselect>
                        <!--- </cfformgroup> --->
                        <!--- END OF CURRENT MAILING ADDRESS --->
                        
                        <cfinput type="checkbox" name="SameAddress" label="Addresses are the same" onClick="#addr#">
                        
                        
                        <!--- PERMANENT MAILING ADDRESS --->
                        <!--- <cfformgroup type="panel" label="Permanent Address"> --->
                              <cfformitem type="hrule" style="" >
                                    <cfinput type="text" label="Number and Street" name="Perm_Address" value="#qGetData.Perm_Address#" required="true" message="" maxlength="255">
                                    <cfinput type="text" label="City" name="Perm_City" value="#qGetData.Perm_City#" required="true" message="" maxlength="255" width="200">
                                    <cfselect name="Perm_State" label="State" maxlength="255" required="true" message="You must enter a State for Permanent Mailing Address" width="100">
                                          <option></option>
                                             <cfloop query="qStates">
                                             <option value="#Abbreviation#" <cfif #qGetData.Perm_State# is #Abbreviation#>selected</cfif>>#Name#</option>
                                          </cfloop>            
                                    </cfselect>
                                    
                                    <cfselect name="Perm_Country" width="200" label="Country" required="true" message="You must a Country for Permanent Mailing Address">
                                             <option></option>
                                          <cfloop query="qCountries">
                                             <option value="#CountryABB#" <cfif #qGetData.Perm_Country# is #CountryAbb#>selected</cfif>>#CountryName#</option>
                                          </cfloop>
                                        </cfselect>
                              </cfformitem>
                        <!--- </cfformgroup> --->
                        </cfformgroup>


this is not working tho, need help please.
                        
0
 
khan02Author Commented:
here is the update from your code, i created a function but when i check the box, it only fills out the fisrt address field (CurrentAdress), and the other one is blank. see code below,

<cfsavecontent variable="SameAddresses">
      if(SameAddresses.selected)
      {
            CurrentAdress.text = PermanentAdress.text;
            Perm_City.text = Con_City.text;
            
      }
</cfsavecontent>

      

<cfform format="flash">
       <!---  <cfinput type="checkbox" name="SameAddresses" label="Addresses are the same" onClick="if(SameAddresses.selected){CurrentAdress.text = PermanentAdress.text;}"> --->
        <cfformgroup type="panel" label="Testing">
                  <cfinput type="text" name="PermanentAdress" label="Permanent Address">
                  <cfinput type="text" name="Perm_City" label="City">
         
            
            <cfinput type="checkbox" name="SameAddresses" label="Addresses are the same" onClick="#SameAddresses#">
             
            
                  <cfinput type="text" name="CurrentAdress" label="Current Address">
                  <cfinput type="text" name="Con_City" label="City">
             </cfformgroup>
</cfform>
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
_agx_Commented:
You have the fields reversed.  I think it should be:

<cfsavecontent variable="SameAddresses">
      if(SameAddresses.selected)
      {
            CurrentAdress.text = PermanentAdress.text;
            Perm_City.text = Con_City.text;
            Con_City.text = Perm_City.text;
      }
</cfsavecontent>
0
 
_agx_Commented:
BTW - If you are using MX 7.0.2 + , you can create functions using cfformitem type="script", instead of using cfcontent.
0
 
khan02Author Commented:
i am using coldfusion Mx 7, still it only duplicates the first field, as i mentioned earlier
0
 
_agx_Commented:
Okay, but there were several updaters to 7, including 7.0.2.  So you should check exactly which version of 7 you are using.  Dump the server scope and it will display the version.

This works fine for me.  It updates the second set of text boxes (current address) with the values from the first (permanent address).  Also, clear your cache to make sure the browser is displaying the updated swf.


<cfsavecontent variable="SameAddresses">
      if(SameAddresses.selected)
      {
            CurrentAdress.text = PermanentAdress.text;
            Con_City.text = Perm_City.text;
            
      }
</cfsavecontent>
 
<cfform format="flash">
       <!---  <cfinput type="checkbox" name="SameAddresses" label="Addresses are the same" onClick="if(SameAddresses.selected){CurrentAdress.text = PermanentAdress.text;}"> --->
        <cfformgroup type="panel" label="Testing">
                  <cfinput type="text" name="PermanentAdress" label="Permanent Address">
                  <cfinput type="text" name="Perm_City" label="City">
         
            
            <cfinput type="checkbox" name="SameAddresses" label="Addresses are the same" onClick="#SameAddresses#">
             
            
                  <cfinput type="text" name="CurrentAdress" label="Current Address">
                  <cfinput type="text" name="Con_City" label="City">
             </cfformgroup>
</cfform>

Open in new window

0
 
khan02Author Commented:
i am using coldfusion Mx 7, still it only duplicates the first field, as i mentioned earlier
0
 
khan02Author Commented:
see below,

ColdFusion Server Developer        7,0,2,142559
Template       /CFD/test10.cfm
Time Stamp       05-Mar-09 03:07 PM
0
 
khan02Author Commented:
it does change the CurrentAddress field with PermanentAddress, but it it does not change field Con_City with Perm_City?
0
 
_agx_Commented:
It works perfectly fine for me.  Did you clear you cache as I mentioned?  If you are still using a cached copy you would not see the changes.  

When I type in a sample address in the first set of textboxes:
 
first address: Perm Address Test
first city:  Perm City Test

It populates the second set of text boxes with the same information when the box is checked:

second address: Perm Address
second city:  Perm City Test

0
 
_agx_Commented:
> it only fills out the fisrt address field (CurrentAdress), and the other one is blank

Stupid questions, but are you _sure_ you:

a) are running the updated code
b) cleared cache
c) typed something in both fields

I ask because I don't really see another reason why the code would not be working for you.  It works perfectly fine for me.

> ColdFusion Server Developer        7,0,2,142559

Yes, then you can use scripts:

0
 
khan02Author Commented:
ok, now it's working for both fields. how can i do the same for STATE and COUNTRY, since state and country fields are <cfselect> type, not a text type?

0
 
_agx_Commented:
If both lists have the same contents, in the _same order_, just use the selectedIndex property instead of "text":

SomeList.selectedIndex = OtherList.selectedIndex;
0
 
khan02Author Commented:
thnks that resolves my problem.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 8
  • 7
Tackle projects and never again get stuck behind a technical roadblock.
Join Now