<!DOCTYPE html>
<html>
<body onload="runOnLoad()">
<p id="info">Check the box to see hubris in action!</p>
<p id="action"><!--Set with JS--></p>
<script>
var topic = "";
var originalText = "";
var transformedText = "";
function runAction() {
if(document.getElementById("box").checked) {
console.log(document.getElementById("box").isChecked)
document.getElementById("action").innerHTML = transformedText;
} else {
document.getElementById("action").innerHTML = originalText;
}
}
function runOnLoad() {
document.getElementById("action").innerHTML = originalText;
document.getElementById("checkBoxText").innerHTML = "Show " + topic;
document.getElementById("info").innerHTML = "Check the box to see " + topic + " in action!";
}
</script>
<form id="myform">
<input type="checkbox" name="checkfield" id="box" onchange="runAction(this)"/> <div style="display: inline-block;" id="checkBoxText"></div>
</form>
</body>
</html>
Comments