By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,341 Members | 1,619 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,341 IT Pros & Developers. It's quick & easy.

Get value of textbox and copy to another text box

P: 75
Hi,

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

i just confuse thx
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <script>
  5. function getValue()
  6.   {
  7.   var x=document.getElementById("myHeader");
  8.   var y=document.getElementById("y");
  9. x.value = y.value;
  10.   alert(x.innerHTML);
  11.   }
  12. </script>
  13. </head>
  14. <body>
  15.  
  16. <h1 id="myHeader" onclick="getValue()">Click me!</h1>
  17. <h1 id="y">me!</h1>
  18. </body>
  19. </html>
  20.  
  21.  
Nov 14 '12 #1
Share this Question
Share on Google+
4 Replies


P: 75
sorry im wrong, thank for viewing,
Expand|Select|Wrap|Line Numbers
  1. textbox2.value = textbox1.value;
sorry again, but if you have other side comment just wright
Nov 14 '12 #2

acoder
Expert Mod 15k+
P: 16,027
You mention a text box, but you're trying to change a H1 element which doesn't have a value.
Nov 14 '12 #3

P: 75
yeah, that's why i been apologizing,
Nov 15 '12 #4

acoder
Expert Mod 15k+
P: 16,027
So, is the problem solved?
Nov 15 '12 #5

Post your reply

Sign in to post your reply or Sign up for a free account.