<script>>
// Wait for DOM to load
document.addEventListener("DOMContentLoaded", function(event) {
// Put the button into a variable
var e = document.getElementById("myForm");
var msg = "";
// Wait for user to click the button
e.addEventListener( "change", function() {
// Put the selected value into a variable
var myColor = this.color.value;
// The "If Else" statement.
if (myColor == "Blue") {
msg = "Just like the sky!";
}
else {
msg = "Didn't pick blue huh?";
}
// Output message
document.getElementById("msg").innerHTML = msg;
}, false);
});
</script>
<form id="myForm" name="myForm" action="{action page}">
<label>
<input type="radio" name="color" value="Blue"> Blue
</label>
<label>
<input type="radio" name="color" value="Red"> Red
</label>
<label>
<input type="radio" name="color" value="Green"> Green
</label>
</form>
<p id="msg"></p>
Комментарии
Отправить комментарий