1 Reply Latest reply on Sep 1, 2006 9:31 AM by ntsiii

    Flex Builder 2

    flexcilence
      Hi,

      Following is code of dynamic form change
      i am using flex builder 2
      the date text field doesn't change dynamically when i change to USA,

      it shows error in script code at this line

      dateOfBirth.dateFormatter = countryIsUK ? mx.utils.Delegate.create( this, formatDateUK ) : mx.utils.Delegate.create( this, formatDateNorthAmerican );


      as multiple markers

      ---------------------------------------------
      <mx:FormItem id="countryItem" label="Country" required="true" >
      <mx:ComboBox id="country" width="350" change="updateUIForCountryChange();">
      <mx:dataProvider>
      <mx:Array>
      <mx:String>UK</mx:String>
      <mx:String>USA</mx:String>
      <mx:String>Canada</mx:String>
      </mx:Array>
      </mx:dataProvider>
      </mx:ComboBox>
      </mx:FormItem>

      <mx:FormItem id="postcodeItem" label="Post Code" required="true" >
      <mx:TextInput id="postcode" width="150" />
      </mx:FormItem>

      <mx:FormItem id="dateOfBirthItem" label="Date of Birth (dd/mm/yyyy)" required="true" >
      <mx:DateField id="dateOfBirth" width="150" dateFormatter="formatDateUK" />
      </mx:FormItem>

      <mx:Script>

      function formatDateUK( date:Date ):String
      {
      return date.getUTCDate() + "-" + ( date.getUTCMonth() + 1 ) + "-" + date.getUTCFullYear();
      }
      function formatDateNorthAmerican( date:Date ):String
      {
      return ( date.getUTCMonth() + 1 ) + "-" + date.getUTCDate() + "-" + date.getUTCFullYear();
      }

      function updateUIForCountryChange()
      {
      var countryIsUK:Boolean = country.value == "UK";

      postcodeItem.label = countryIsUK ? "Post Code" : "Zip Code";
      dateOfBirthItem.label = countryIsUK ? "Date of Birth (dd/mm/yyyy)" : "Date of Birth (mm/dd/yyyy)";

      dateOfBirth.dateFormatter = countryIsUK ? mx.utils.Delegate.create( this, formatDateUK ) : mx.utils.Delegate.create( this, formatDateNorthAmerican );
      }
      </mx:Script>

      any one please help me out

      Thanks