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

Java/HTML buttons and forms help

P: 5
I used to know how to do this, but I lost alot of my old files on my old computer.

I'm trying to create a page that has different buttons on top (I know how to create the buttons), but then depending on which button is clicked, I want it to post text to a textarea. It would have to be a textarea because the text being posted is html code. I would appreciate any and all help. Thanks!

Karyn
Dec 7 '06 #1
Share this Question
Share on Google+
3 Replies


P: 26
I used to know how to do this, but I lost alot of my old files on my old computer.

I'm trying to create a page that has different buttons on top (I know how to create the buttons), but then depending on which button is clicked, I want it to post text to a textarea. It would have to be a textarea because the text being posted is html code. I would appreciate any and all help. Thanks!

Karyn
If you are trying to do something with buttons and javascript, heres an idea. Not sure if it's exactly what you want.....

Paste this HTML code into a text editor and save as a HTML page:

Expand|Select|Wrap|Line Numbers
  1.  
  2. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  3. "http://www.w3.org/TR/html4/loose.dtd">
  4. <html>
  5. <head>
  6.  
  7. <script type="text/javascript" >
  8.  
  9. function pasteCode(e) {
  10. var Code = "";
  11. if(e.name == "But1") {
  12. Code = "You chose the BODY section of this page\n <body>\n<form name='buttonForm' action=''>\n</form>\n</body>"
  13. document.buttonForm.codeDisplay.value =Code;
  14. }
  15. if(e.name == "But2") {
  16. Code = "You chose the HEAD section of this page\n <head></head>"
  17. document.buttonForm.codeDisplay.value =Code;
  18. }
  19. if(e.name == "But3") {
  20. var Code = "You chose the NO CODE section of this page. Hit another one please....."
  21. document.buttonForm.codeDisplay.value =Code;
  22. }
  23. if(e.name == "But4") {
  24. var Code = "OK you get the idea now don't you!"
  25. document.buttonForm.codeDisplay.value =Code;
  26. }
  27.  
  28. }
  29.  
  30.  
  31. </script>
  32. <title>Button fun</title>
  33. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  34. </head>
  35.  
  36. <body>
  37. <form name="buttonForm" action="">
  38. <input name="But1" type="button" value="#1 - Click me!" onClick="pasteCode(this)">
  39. <input name="But2" type="button" value="#2 - Click me!" onClick="pasteCode(this)">
  40. <input name="But3" type="button" value="#3 - Click me!" onClick="pasteCode(this)">
  41. <input name="But4" type="button" value="#4 - Click me!" onClick="pasteCode(this)">
  42.  
  43. <input type="reset" name="reset" value="Reset"/>
  44. <br/>
  45. <br/>
  46. <textarea name="codeDisplay" cols="100" rows="30">Hit a button and see what HTML stuff gets posted....</textarea>
  47. </form>
  48. </body>
  49. </html>
  50.  
Dec 7 '06 #2

P: 5
thank you very much! that's exactly what I was looking for :)
Dec 7 '06 #3

P: 5
ok, that works when i preview it in my editor, but then when i actually go to the website, it doesn't work... :(
www.geocities.com/hottieinyourdreams420/main.html
Dec 7 '06 #4

Post your reply

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