iamtheyammer

Change paragraph, variables

Oct 30th, 2018
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <body onload="runOnLoad()">
  4.  
  5. <p id="info">Check the box to see hubris in action!</p>
  6. <p id="action"><!--Set with JS--></p>
  7.  
  8. <script>
  9. var topic = "";
  10. var originalText = "";
  11. var transformedText = "";
  12.  
  13. function runAction() {
  14. if(document.getElementById("box").checked) {
  15. console.log(document.getElementById("box").isChecked)
  16. document.getElementById("action").innerHTML = transformedText;
  17. } else {
  18. document.getElementById("action").innerHTML = originalText;
  19. }
  20. }
  21. function runOnLoad() {
  22. document.getElementById("action").innerHTML = originalText;
  23. document.getElementById("checkBoxText").innerHTML = "Show " + topic;
  24. document.getElementById("info").innerHTML = "Check the box to see " + topic + " in action!";
  25. }
  26. </script>
  27.  
  28. <form id="myform">
  29. <input type="checkbox" name="checkfield" id="box" onchange="runAction(this)"/> <div style="display: inline-block;" id="checkBoxText"></div>
  30. </form>
  31.  
  32. </body>
  33. </html>
Advertisement
Add Comment
Please, Sign In to add comment