1 Reply Latest reply on Sep 22, 2008 11:54 AM by ntsiii

    Need Help In Reset Function

    saint-michael
      I am trying to work on a reset function for a flex form and I am in a stumbling block I can't find a way to reset a combobox.

      This is what I have so far

      <mx:Script>
      <![CDATA[

      private function resetForm():void {
      fname.text = '';
      mname.text = '';
      lname.text = '';
      dob.text = '';
      email.text = '';
      age.text = '';
      ssn.text = '';
      city.text = '';
      zip.text = '';
      phone.text = '';
      credit.text = '';
      }
      ]]>
      </mx:Script>

      Here are the combo boxes that I am trying to reset

      <mx:ComboBox id="cardType">
      <mx:dataProvider>
      <mx:Object label="None" data="None"/>
      <mx:Object label="American Express" data="American Express"/>
      <mx:Object label="Discover" data="Discover"/>
      <mx:Object label="MasterCard" data="MasterCard"/>
      <mx:Object label="Visa" data="Visa"/>
      </mx:dataProvider>
      </mx:ComboBox>

      <mx:FormItem label="State">
      <mx:ComboBox id="state">
      <mx:dataProvider>
      <mx:Object label="None" data="None"/>
      <mx:Object label="Alabama" data="Alabama"/>
      <mx:Object label="Alaska" data="Alaska"/>
      <mx:Object label="Arizona" data="Arizona"/>
      <mx:Object label="Arkansas" data="Arkansas"/>
      <mx:Object label="California" data="California"/>
      <mx:Object label="Colorado" data="Colorado"/>
      <mx:Object label="Connecticut" data="Connecticut"/>
      <mx:Object label="Delaware" data="Delaware"/>
      <mx:Object label="District of Columbia" data="District of Columbia"/>
      <mx:Object label="Florida" data="Florida"/>
      <mx:Object label="Georgia" data="Georgia"/>
      <mx:Object label="Hawaii" data="Hawaii"/>
      <mx:Object label="Idaho" data="Idaho"/>
      <mx:Object label="Illinois" data="Illinois"/>
      <mx:Object label="Indiana" data="Indiana"/>
      <mx:Object label="Iowa" data="Iowa"/>
      <mx:Object label="Kansas" data="Kansas"/>
      <mx:Object label="Kentucky" data="Kentucky"/>
      <mx:Object label="Louisiana" data="Louisiana"/>
      <mx:Object label="Maine" data="Maine"/>
      <mx:Object label="Maryland" data="Maryland"/>
      <mx:Object label="Massachusetts" data="Massachusetts"/>
      <mx:Object label="Michigan" data="Michigan"/>
      <mx:Object label="Minnesota" data="Minnesota"/>
      <mx:Object label="Mississippi" data="Mississippi"/>
      <mx:Object label="Missouri" data="Missouri"/>
      <mx:Object label="Montana" data="Montana"/>
      <mx:Object label="Nebraska" data="Nebraska"/>
      <mx:Object label="Nevada" data="Nevada"/>
      <mx:Object label="New Hampshire" data="New Hampshire"/>
      <mx:Object label="New Jersey" data="New Jersey"/>
      <mx:Object label="New Mexico" data="New Mexico"/>
      <mx:Object label="New York" data="New York"/>
      <mx:Object label="North Carolina" data="North Carolina"/>
      <mx:Object label="North Dakota" data="North Dakota"/>
      <mx:Object label="Ohio" data="Ohio"/>
      <mx:Object label="Oklahoma" data="Oklahoma"/>
      <mx:Object label="Oregon" data="Oregon"/>
      <mx:Object label="Pennsylvania" data="Pennsylvania"/>
      <mx:Object label="Rhode Island" data="Rhode Island"/>
      <mx:Object label="South Carolina" data="South Carolina"/>
      <mx:Object label="South Dakota" data="South Dakota"/>
      <mx:Object label="Tennessee" data="Tennessee"/>
      <mx:Object label="Texas" data="Texas"/>
      <mx:Object label="Utah" data="Utah"/>
      <mx:Object label="Vermont" data="Vermont"/>
      <mx:Object label="Virginia" data="Virginia"/>
      <mx:Object label="Washington" data="Washington"/>
      <mx:Object label="West Virginia" data="West Virginia"/>
      <mx:Object label="Wisconsin" data="Wisconsin"/>
      <mx:Object label="Wyoming" data="Wyoming"/>
      </mx:dataProvider>
      </mx:ComboBox>
      </mx:FormItem>

      So is there any way to add a reset function for a combo box in that script?
        • 1. Re: Need Help In Reset Function
          ntsiii Level 3
          This forum is essentially dead. all the action is on the General discussion forum.

          Are you really using Flex 1.5?

          I don't really know what you mean by "reset", but if you do the following, the Combo box will display no selection:
          state.selectedIndex = -1;

          If you define a string for the "prompt" property, that will also be displayed.

          Tracy