3.2.0

ability to clear input text on activattion

Hi,

im trying to do something like this : www.tv.com (look at the search bar)
the word search disappears when clicked, and reappears if nothing is typed in the input.
i managed to make the text disappear using :

input_isb1.onControlActivated = function(event){
if (input_isb1.getControlText() == "search")
{
input_isb1.setControlText("");
}
}

but this causes problems when i want the text to reappear, because if i use :
input_isb1.onControlDeactivating = function(event){
if (input_isb1.getControlText() == "")
{
input_isb1.setControlText("search"); }
}

it will make the word "search" re-appear in the text input no matter if its empty or not. (meaning if i type something instead of leaving it empty, the word "search" will override the text i entered)

any ideas?

Thanks!!
iceman
December 25,
Haven't checked if this works, but try using input_isb1.onControlEditEnded instead of input_isb1.onControlDeactivating

Ankur
Ankur Motreja
December 26,
didn't work.
i've noticed that with

input_isb1.onControlDeactivating or
input_isb1.onControlDeactivated

does capture the event, but the
input_isb1.setControlText(""); from input_isb1.onControlActivated
makes the text input value empty regardless of whther i type anything in it or not.
iceman
December 26,
Hi,

I just tried this out and it seems to work fine with your code in FF 2.0 and IE7.
The exact code I used is below.
Maybe its something in another part of your code ?

Regards,
Ankur

var input_isb1 = new AW.UI.Input;
input_isb1.setControlText("search");

input_isb1.onControlActivated = function(event){
  if (input_isb1.getControlText() == "search")
  {
    input_isb1.setControlText("");
  }
}

input_isb1.onControlDeactivating = function(event){
  if (input_isb1.getControlText() == "")
  {
    input_isb1.setControlText("search");
  }
}

document.write(input_isb1);
Ankur Motreja
December 26,
did you try typing something in the text input, focusing on another UI element and coming back to the text input?
the text written in the input will be automatically replaced by "search"
iceman
December 26,
Hi,

Yes, I tried that and it retains the text I typed in.
Just try the code I've posted above in a separate page without any other elements and see if that works fine.
BTW, which browser are you using ?

Ankur
Ankur Motreja
December 26,
Hey Ankur,

i tried the above code alone in both IE and FF....

whenever i click on the text input the word search clears, i wrtite something, move the focus away from the input and bring it back, it gets replaced by the word search again

if it works on your side, it might be that the version of Astive widgets that im running now has a bug.
are you running 2.0.1?
im running 2.0
iceman
December 27,
i tried the 2.0.1 trial, and it worked, so i have to update my version...

Thanks for all your help =)
iceman
December 27,
Actually i want to make dyanamic combo box.
if i will select value from combobox like day,week,months,year then
another combo box should be come in run time.
Pintu
December 27,

This topic is archived.

See also:


Back to support forum