tarun Posted October 3, 2007 Share Posted October 3, 2007 Is it possible to jump to a certain line or location in a textarea tag. And if so can you provide an example.. thnx... Tarun Link to comment https://forums.phpfreaks.com/topic/71728-solved-textarea-jump-to-certain-line/ Share on other sites More sharing options...
php_tom Posted October 3, 2007 Share Posted October 3, 2007 Try this code, based on a function from http://www.faqts.com/knowledge_base/view.phtml/aid/15728: <html> <head> <script> function setCursorPosition(oInput,oStart,oEnd) { if( oInput.setSelectionRange ) { oInput.setSelectionRange(oStart,oEnd); } else if( oInput.createTextRange ) { var range = oInput.createTextRange(); range.collapse(true); range.moveEnd('character',oEnd); range.moveStart('character',oStart); range.select(); } } </script> </head> <body onload='txt.focus();setCursorPosition(txt,10,10);//move to 10th character'> <textarea id='txt'>A bunch of text that hopefully will make this textarea end up having multiple lines in it. Have I blabbae enough yet? Yeah, I thought so...</textarea> </body> </html> Works in FF and IE. Hope it helps. Link to comment https://forums.phpfreaks.com/topic/71728-solved-textarea-jump-to-certain-line/#findComment-361254 Share on other sites More sharing options...
tarun Posted October 4, 2007 Author Share Posted October 4, 2007 THANK YOU SO MUCH Link to comment https://forums.phpfreaks.com/topic/71728-solved-textarea-jump-to-certain-line/#findComment-361836 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.