2 Replies Latest reply on Oct 31, 2007 10:01 PM by atta707

    reset textInput field

    mark416 Level 1
      Hi,

      I build a data entry application with two screens.you can input name in textInput field in first screen and the second screen have
      a "save next" button and the application go to screen one when you click the button,then you can add next new record.

      my question is the textInput field always have last time data when I go to screen next time.I hope the textInput field is empty when I come to the first screen from the second screen .Please let me know how to do this.Thanks

      my code is here:

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute">
      <mx:states>
      <mx:State name="results">
      <mx:RemoveChild target="{nameInput}"/>
      <mx:SetProperty target="{label1}" name="x" value="129"/>
      <mx:SetProperty target="{label1}" name="y" value="62"/>
      <mx:SetProperty target="{label1}" name="text" value="Data is saved"/>
      <mx:SetProperty target="{label1}" name="width" value="130"/>
      <mx:SetProperty target="{button1}" name="label" value="Input Next Record"/>
      <mx:SetProperty target="{button1}" name="width" value="177"/>
      <mx:SetEventHandler target="{button1}" name="click" handler="currentState=''"/>
      </mx:State>
      </mx:states>
      <mx:Label x="98" y="67" text="Name:" width="61" id="label1"/>
      <mx:TextInput x="167" y="65" id="nameInput" />
      <mx:Button x="129" y="118" label="save" id="button1" width="170" click="currentState='results'"/>

      </mx:Application>
        • 1. Re: reset textInput field
          Gregory Lafrance Level 6
          In the code below I changed the SetEventHandler:

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute">
          <mx:states>
          <mx:State name="results">
          <mx:RemoveChild target="{nameInput}"/>
          <mx:SetProperty target="{label1}" name="x" value="129"/>
          <mx:SetProperty target="{label1}" name="y" value="62"/>
          <mx:SetProperty target="{label1}" name="text" value="Data is saved"/>
          <mx:SetProperty target="{label1}" name="width" value="130"/>
          <mx:SetProperty target="{button1}" name="label" value="Input Next Record"/>
          <mx:SetProperty target="{button1}" name="width" value="177"/>
          <mx:SetEventHandler target="{button1}" name="click" handler="currentState='';nameInput.text=''"/>
          </mx:State>
          </mx:states>
          <mx:Label x="98" y="67" text="Name:" width="61" id="label1"/>
          <mx:TextInput x="167" y="65" id="nameInput" />
          <mx:Button x="129" y="118" label="save" id="button1" width="170" click="currentState='results'"/>

          </mx:Application>
          • 2. Re: reset textInput field
            atta707 Level 2
            or alternatively, just before going to the results state set the text value to empty:

            <mx:Button x="129" y="118" label="save" id="button1" width="170" click="nameInput.text = ''; currentState='results'"/>

            ATTA