We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

Coldfusion Flash form CF7

khan02
khan02 asked
on
Medium Priority
231 Views
Last Modified: 2013-12-24
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
Comment
Watch Question

CERTIFIED EXPERT
Most Valuable Expert 2015

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

Author

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.
                        

Author

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>
CERTIFIED EXPERT
Most Valuable Expert 2015

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>
CERTIFIED EXPERT
Most Valuable Expert 2015

Commented:
BTW - If you are using MX 7.0.2 + , you can create functions using cfformitem type="script", instead of using cfcontent.

Author

Commented:
i am using coldfusion Mx 7, still it only duplicates the first field, as i mentioned earlier
CERTIFIED EXPERT
Most Valuable Expert 2015
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

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

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

Author

Commented:
see below,

ColdFusion Server Developer        7,0,2,142559
Template       /CFD/test10.cfm
Time Stamp       05-Mar-09 03:07 PM

Author

Commented:
it does change the CurrentAddress field with PermanentAddress, but it it does not change field Con_City with Perm_City?
CERTIFIED EXPERT
Most Valuable Expert 2015

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

CERTIFIED EXPERT
Most Valuable Expert 2015

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:

Author

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?

CERTIFIED EXPERT
Most Valuable Expert 2015

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

SomeList.selectedIndex = OtherList.selectedIndex;

Author

Commented:
thnks that resolves my problem.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.