Foucs on a Text Box using javascript?
-
document.getElementByid("TextBoxID").focus();
Parwej Ahamad g.parwez@gmail.com
-
We usually do something like this:
function LoadFocus(){ document.getElementById('<%= <TextBoxName>.ClientID %>').focus(); document.getElementById('<%= <TextBoxName>.ClientID %>').select(); } window.attachEvent("onload", LoadFocus); }
This will work for IE, but not sure about attachEvent for ff...would have to check if required. -
We usually do something like this:
function LoadFocus(){ document.getElementById('<%= <TextBoxName>.ClientID %>').focus(); document.getElementById('<%= <TextBoxName>.ClientID %>').select(); } window.attachEvent("onload", LoadFocus); }
This will work for IE, but not sure about attachEvent for ff...would have to check if required.daniel__c wrote:
document.getElementById('<%= .ClientID %>').select();
Why do we need to do that?
Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. :)
-
daniel__c wrote:
document.getElementById('<%= .ClientID %>').select();
Why do we need to do that?
Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. :)
Sorry, that should be document.getElementById('<%= .ClientID %>') not document.getElementById('<%= .ClientID %>') as originally posted. We usually do the .select() to select any text that is currently in the text box. You can do the focus alone, but the select tends to be a bit more user friendly.