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 Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
tarun Posted October 4, 2007 Author Share Posted October 4, 2007 THANK YOU SO MUCH Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.