views:

259

answers:

1

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.

+3  A: 

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;
}
</script>

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