Hi, anyone any useful code for getting a textbox and/or textarea to expand automatically to fit its contents? Setting width in 'ch' units is too hit and miss. I also need to constrain the width within draggable table column widths so entry controls also need to resize if column widths are changed.
06/17/2009 - 09:07
I don't think there's any easy way to do this. Here's the best approach I can think of:
1. Use an off-screen span to measure the width of your text in pixels. Similar to this approach.
2. Use CSS and the width property to set the width of the textarea in pixels instead of cols based on the width determined by step 1.
Add Comment
[language] [/language]
Examples:
[javascript] [/javascript]
[actionscript] [/actionscript]
[csharp] [/csharp]
See here for supported languages.
Javascript must be enabled to submit anonymous comments - or you can login.