javascript - How to auto-adjust size of other input fields while typing into input field #1? -


i working html/javascript/css page looks this,

       input field: (base10) [100                  ] output field #1 (base08) [144                  ] output field #2 (base19) [55                   ] output field #3 (base36) [2s                   ] 

and trying achieve this,

       input field: (base10) [100                  ] output field #1 (base08) [144] output field #2 (base19) [55] output field #3 (base36) [2s] 

with real-time adjustment "output" field sizes. brackets denote field sizes visible on screen. how code that?

all 4 of lines use html input tag unique id's. in case typed "100" base10 field arbitrarily long in size, , in real time javascript updates multiple output fields number 100 written in other counting systems, , works fine, no problem there.

the problem output fields pre-determined/hard-coded size, whereas contents different sizes. need size attribute of fields called #1, #2, , #3 dynamically updated in real time too, field snugly fits each of contents.

something tells me solution involve things onkeyup="resize(this);" , document.getelementsbyname or similar (preferably no jquery), not best javascript syntax , modding pre-written page under gnu gpl, need help.

thanks!

solved myself :

document.getelementbyid("foo").style.width = ((document.getelementbyid("foo").value.length + 1) * 6.5);  

it's pretty close, not 100%, far style width matching input element contents, @ least it's dynamic looking for.


Comments

Popular posts from this blog

c - How to retrieve a variable from the Apache configuration inside the module? -

c# - Constructor arguments cannot be passed for interface mocks -

python - malformed header from script index.py Bad header -