Copy contents of one textbox to another

后端 未结 7 1195
梦毁少年i
梦毁少年i 2021-02-02 00:38

Suppose an entry is made in a textbox. Is it possible to retain the same entered text in a second text box? If so, how is this done?


      
7条回答
  •  甜味超标
    2021-02-02 01:20

    Well, you have two textboxes with the same ID. An Id should be unique, so you should prbably change this.

    To set the value from one text box to another a simple call to getElementById() should suffice:

    document.getElementById("n1").value=  document.getElementById("n2").value;
    

    (assuming, of course you give your secodn text box an id of n2)

    Tie this up to a button click to make it work.

提交回复
热议问题