LiamGu LiamGu - 8 months ago 22
Javascript Question

Create a text box with an auto-expanding width?

How would I go about creating a textbox with an auto-expanding width to fit it's content?

I keep finding plenty of info on height based expansions but not much on width.

I'd also like it to apply to every textbox on the page and not just specific ones.

Wil Wil

Not sure if this is what you had in mind, but shouldn't this work?

<script language="javascript">
function expand(f)
    f.size = f.size + 1;

<input type="text" size="20" onkeyup="expand(this)" />