Get value of textbox and copy to another text box

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lyodmichael
    New Member
    • Jul 2012
    • 75

    Get value of textbox and copy to another text box

    Hi,

    how to get the value of textbox and copy to other textbox,

    i just confuse thx
    Code:
    <!DOCTYPE html>
    <html>
    <head>
    <script>
    function getValue()
      {
      var x=document.getElementById("myHeader");
      var y=document.getElementById("y");
    x.value = y.value;
      alert(x.innerHTML);
      }
    </script>
    </head>
    <body>
    
    <h1 id="myHeader" onclick="getValue()">Click me!</h1>
    <h1 id="y">me!</h1>
    </body>
    </html>
  • lyodmichael
    New Member
    • Jul 2012
    • 75

    #2
    sorry im wrong, thank for viewing,
    Code:
    textbox2.value = textbox1.value;
    sorry again, but if you have other side comment just wright

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      You mention a text box, but you're trying to change a H1 element which doesn't have a value.

      Comment

      • lyodmichael
        New Member
        • Jul 2012
        • 75

        #4
        yeah, that's why i been apologizing,

        Comment

        • acoder
          Recognized Expert MVP
          • Nov 2006
          • 16032

          #5
          So, is the problem solved?

          Comment

          Working...