# Clear input field when selected

**URL:** <https://forum.kirupa.com/t/clear-input-field-when-selected/275721>\
**Category:** Uncategorized\
**Created:** [November 17, 2008, 10:14pm UTC](https://forum.kirupa.com/t/clear-input-field-when-selected/275721 "2008-11-17T22:14:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![koala\_kid](https://avatars.discourse-cdn.com/v4/letter/k/898d66/32.png) [@koala\_kid](https://forum.kirupa.com/u/koala_kid)\
**Post date:** [November 17, 2008, 10:14pm UTC](https://forum.kirupa.com/t/clear-input-field-when-selected/275721/1 "2008-11-17T22:14:34Z")

</div>

Hi, I have a simple serch textfield and want to be able to clear the text currently in the field once a user clicks on i. I’ve tried the below but its not working:

var changed = false;  
//search\_txt.addListener(someListener);  
search\_txt.onChanged= function(){  
if(changed == false){  
this.text = ‘’;  
changed = true;  
}  
}
