2

i'm trying to get an input box to get auto-selected when the user clicks on it the code i'm using :

<input type="text" onclick="this.focus();this.select();" value="i like pie">

tried with the solution provided here

the problem is that the code works for FF, Opera, Internet Explorer 8/7 but not for IE 6... any ideas how to make it work for IE6 too ?

Community
  • 1
  • 1
Raz
  • 682
  • 1
  • 7
  • 19

2 Answers2

1

I was having this problem in IE7, and tried wrapping it in a timeout, which worked...even a timeout of 0ms worked.

window.setTimeout(function(){
    target.select();
}, 0);
1

The code works for me too.

If you don't have JavaScript enabled in your browser, your code wouldn't work. Check if JavaScript is enabled.