dynamic size for input box

I have an input box which needs to be able to change in size depending on the number of characters that are fed into it when the page is loaded. Is there a way of setting the size="" parameter to take in a dynamic variable equal to the length of the figure fed into it?

At the moment it just renders at a fixed size and that doesn't accomodate to my design wishes.