Created
March 23, 2017 00:21
-
-
Save dursk/0f64b9dad30831a56e77df789c10a109 to your computer and use it in GitHub Desktop.
Exported from Popcode. Click to import: https://popcode.org/?gist=0f64b9dad30831a56e77df789c10a109
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Page Title</title> | |
</head> | |
<body> | |
<h1>Movie Ratings</h1> | |
<div class="rating"> | |
<h3>Select a rating:</h3> | |
<input type="radio" name="rating" value="G"> G <br> | |
<input type="radio" name="rating" value="PG"> PG <br> | |
<input type="radio" name="rating" value="PG-13"> PG-13 <br> | |
<input type="radio" name="rating" value="R"> R <br> | |
</div> | |
<div class="age"> | |
<h3>Enter your age:</h3> | |
<input type="number" name="age"> | |
</div> | |
<div> | |
<button>Am I old enough to see the movie?</button> | |
<p id="response"></p> | |
</div> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"enabledLibraries":["jquery"]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Write a function called isOldEnough that takes in two parameters: | |
// 1. The movie rating that is selected. | |
// 2. The age entered. | |
// The function should then check if the person is old enough | |
// and return true or false. | |
// | |
// Age brackets: | |
// G: ages 0 and older | |
// PG: ages 3 and older | |
// PG-13: ages 13 and older | |
// R: ages 17 and older | |
// | |
// When you click the button, you should call the isOldEnough function, | |
// and store the result in a variable. | |
// Then display "Yes" or "No" based on what the result is. | |
$("button").click(function() { | |
var rating = $("input[name=rating]:checked").val(); | |
var age = $("input[name=age]").val(); | |
$("#response").html('No!'); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.rating input { | |
margin: 8px; | |
} | |
.age input { | |
height: 20px; | |
width: 50px; | |
} | |
button { | |
margin-top: 25px; | |
height: 30px; | |
font-size: 15px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment