jimmyoneshot Posted August 7, 2011 Share Posted August 7, 2011 I'm trying to emulate exactly how a div with the attribute contentEditable = "true" would operate using a textarea...trying and failing. I found some code somewhere which attempts to do something like his but it isn't working well for me. I want to do this without jquery and with javascript only. The best example I can think of is Facebook's text area that you use to write on somebody's wall. Here's my sizing function function sz(t) { a = t.value.split('\n'); b=1; for (x=0;x < a.length; x++) { if (a[x].length >= t.cols) b+= Math.floor(a[x].length/t.cols); } b+= a.length; if (b > t.rows) t.rows = b; } and here's my text area:- <textarea id="text_entry" rows="1" cols="1" onkeyup="sz(this)" >User text goes here</textarea> Quote Link to comment https://forums.phpfreaks.com/topic/244147-emulating-div-contenteditable-true-with-textarea/ 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.