CodeIgniter Forums
Setfocus on textfield - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Setfocus on textfield (/showthread.php?tid=29677)



Setfocus on textfield - El Forum - 04-17-2010

[eluser]01010011[/eluser]
Hi,

How do I set the insertion point in an HTML text field? I am using the form_open function and all of the examples I see on the Web require the use of the form name and a little Javascript.


Setfocus on textfield - El Forum - 04-17-2010

[eluser]eoinmcg[/eluser]
with jquery:

Code:
// for the first textfield on the doc
$(document).ready(function(){
    $('textarea:first').focus();
});

Code:
// select textfield by id
$(document).ready(function(){
    $('textarea#id_name:first').focus();
});



Setfocus on textfield - El Forum - 04-17-2010

[eluser]01010011[/eluser]
Thanks for your reply eoinmcg. I will try it.

[quote author="eoinmcg" date="1271559711"]with jquery:

Code:
// for the first textfield on the doc
$(document).ready(function(){
    $('textarea:first').focus();
});

Code:
// select textfield by id
$(document).ready(function(){
    $('textarea#id_name:first').focus();
});
[/quote]