Tuesday, December 6, 2011

reset textInput field

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:



%26lt;?xml version=''1.0'' encoding=''utf-8''?%26gt;

%26lt;mx:Application xmlns:mx=''
http://www.adobe.com/2006/mxml''
layout=''absolute''%26gt;

%26lt;mx:states%26gt;

%26lt;mx:State name=''results''%26gt;

%26lt;mx:RemoveChild target=''{nameInput}''/%26gt;

%26lt;mx:SetProperty target=''{label1}'' name=''x''
value=''129''/%26gt;

%26lt;mx:SetProperty target=''{label1}'' name=''y''
value=''62''/%26gt;

%26lt;mx:SetProperty target=''{label1}'' name=''text'' value=''Data
is saved''/%26gt;

%26lt;mx:SetProperty target=''{label1}'' name=''width''
value=''130''/%26gt;

%26lt;mx:SetProperty target=''{button1}'' name=''label''
value=''Input Next Record''/%26gt;

%26lt;mx:SetProperty target=''{button1}'' name=''width''
value=''177''/%26gt;

%26lt;mx:SetEventHandler target=''{button1}'' name=''click''
handler=''currentState=''''/%26gt;

%26lt;/mx:State%26gt;

%26lt;/mx:states%26gt;

%26lt;mx:Label x=''98'' y=''67'' text=''Name:'' width=''61''
id=''label1''/%26gt;

%26lt;mx:TextInput x=''167'' y=''65'' id=''nameInput'' /%26gt;

%26lt;mx:Button x=''129'' y=''118'' label=''save'' id=''button1''
width=''170'' click=''currentState='results'''/%26gt;



%26lt;/mx:Application%26gt;reset textInput field
In the code below I changed the SetEventHandler:



%26lt;?xml version=''1.0'' encoding=''utf-8''?%26gt;

%26lt;mx:Application xmlns:mx=''
http://www.adobe.com/2006/mxml''
layout=''absolute''%26gt;

%26lt;mx:states%26gt;

%26lt;mx:State name=''results''%26gt;

%26lt;mx:RemoveChild target=''{nameInput}''/%26gt;

%26lt;mx:SetProperty target=''{label1}'' name=''x''
value=''129''/%26gt;

%26lt;mx:SetProperty target=''{label1}'' name=''y'' value=''62''/%26gt;

%26lt;mx:SetProperty target=''{label1}'' name=''text'' value=''Data
is saved''/%26gt;

%26lt;mx:SetProperty target=''{label1}'' name=''width''
value=''130''/%26gt;

%26lt;mx:SetProperty target=''{button1}'' name=''label''
value=''Input Next Record''/%26gt;

%26lt;mx:SetProperty target=''{button1}'' name=''width''
value=''177''/%26gt;

%26lt;mx:SetEventHandler target=''{button1}'' name=''click''
handler=''currentState='';nameInput.text=''''/%26gt;

%26lt;/mx:State%26gt;

%26lt;/mx:states%26gt;

%26lt;mx:Label x=''98'' y=''67'' text=''Name:'' width=''61''
id=''label1''/%26gt;

%26lt;mx:TextInput x=''167'' y=''65'' id=''nameInput'' /%26gt;

%26lt;mx:Button x=''129'' y=''118'' label=''save'' id=''button1''
width=''170'' click=''currentState='results'''/%26gt;



%26lt;/mx:Application%26gt;reset textInput field
or alternatively, just before going to the results state set
the text value to empty:



%26lt;mx:Button x=''129'' y=''118'' label=''save'' id=''button1''
width=''170'' click=''nameInput.text = '';
currentState='results'''/%26gt;



ATTA

No comments:

Post a Comment