LiamGu LiamGu - 2 years ago 92
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
Answer Source

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)" />
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download