function doit(){ var name1="1"; console.log(name1); name1=document.getElementsByClassName('form1')[0].value; document.getElementsByClassName('form2')[0].innerHTML=name1; console.log(name1); };