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

How To Carry Over Text Values (Simple Solution?)

chunk1978
100+
P: 224
hi there... i'm trying to make one text field contain the value of another... i'm assuming there's a really simple solution... here's a code i quickly wrote to further explain my issue:

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
  5. <title>Untitled Document</title>
  6. </head>
  7. <script type="text/javascript">
  8.  
  9. function Carry
  10.     {document.form1.textfield2.value = document.form1.textfield.value;}
  11.  
  12. </script>
  13.  
  14. <body>
  15. <form id="form1" name="form1" method="post" action="">
  16. <p>
  17.   <input name="submit" type="button" id="submit" value="Carry Over Value" onclick="Carry();" />
  18. </p>
  19. <p>
  20.   <input name="textfield" id="textfield" type="text" value="Duplicate me!" />
  21.   <input name="textfield2" id="textfield2" input type="text" value="Erase me!"/>
  22. </form>
  23. <p>&nbsp;</p>
  24. </body>
  25. </html>
  26.  
thanks in advance! :-)
Feb 20 '07 #1
Share this Question
Share on Google+
3 Replies


chunk1978
100+
P: 224
oh... i forgot the "()" at the end of the JS function... but still, the result is the same [still doesn't work] when added...
Feb 20 '07 #2

chunk1978
100+
P: 224
nevermind... seems to be working now (???)...

dumb...
Feb 20 '07 #3

acoder
Expert Mod 15k+
P: 16,027
I know it was only an example, but you shouldn't use 'submit' for a normal button to avoid confusion.
Feb 20 '07 #4

Post your reply

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