There is a little code, I made it with the help of another topic and with a little thought with my head.

var a=(document.getElementsByName("products_qty")[0].value); document.write(a); 

This variable is written to the value entered in the input field. And how I would like (for a long time to explain) that this same value be duplicated elsewhere on the page. Ie I change the value in the input field - the value of the variable a also changes.

Probably, you can somehow push off from the fact that the input knows such a chip as a trick. Those. It seems to me that you can somehow force the value to change as soon as I stop typing numbers.

  • one
    onfocus on the input and on onkeyup perform an anonymous function that will assign the value of the input variable to the moment any key is pressed! Boogie, do not wait for a solution! I would write a script, but unfortunately, not in that mood! - Palmervan
  • one
    sure, not a problem. mneb and it was necessary only starting points. I do not like when someone writes a code for me. thanks - KoVaLsKy
  • one
    Brackets are not needed. - karmadro4
  • I tried to add onkeyup = "thisqty () to the input and insert the function thisqty () {var a = document.getElementsByName (" products_qty ") [0] .value; document.write (a);} as soon as I enter something , then the value I have entered appears on the white field, but the page disappears. ((( - KoVaLsKy
  • one
    The disappearance of the page already clearly hints that it is time to stop begging snippets and start reading manuals. - karmadro4

1 answer 1

 <style> #fortextdiv{ width: 100px; height: 50px; background-color: #00FF00; } </style> <script> function change(inpid,divid){ var inpobj=document.getElementById(inpid); var divobj=document.getElementById(divid); divobj.innerHTML=inpobj.value; } </script> <div id="fortextdiv"></div> <input type="text" id="fortextinput" onkeydown="change('fortextinput','fortextdiv')" value=""> 
  • Thank you, kind man! - KoVaLsKy
  • @KoVaLsKy Accept the answer if it suits you (by clicking the check mark next to the answer) - Rules
  • just noticed. displays the previous value entered. I first enter 1, nothing is output I enter 2 displays 1 - KoVaLsKy
  • one
    You can replace onKeyDown with onKeyUp - Rules
  • beauty. Thank you - KoVaLsKy