Created
December 19, 2017 21:28
-
-
Save haakym/9acc2bc9ae7ac13da19ec26780bf0edd to your computer and use it in GitHub Desktop.
Word Assignment
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> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>Word Assignment</title> | |
<style> | |
#wordAssignmentForm > div, .grammer-entities > div { | |
margin: 1em; | |
} | |
#wordsCheckboxes > label { | |
display: block; | |
} | |
</style> | |
</head> | |
<body> | |
<h2>Word Assignment</h2> | |
<form id="wordAssignmentForm"> | |
<div id="wordsCheckboxes"> | |
<h3>Words</h3> | |
<label for="Slow"> | |
<input type="checkbox" name="words" value="slow"> Slow | |
</label> | |
<label for="Fast"> | |
<input type="checkbox" name="words" value="fast"> Fast | |
</label> | |
<label for="Cat"> | |
<input type="checkbox" name="words" value="cat"> Cat | |
</label> | |
<label for="Dog"> | |
<input type="checkbox" name="words" value="dog"> Dog | |
</label> | |
<label for="Think"> | |
<input type="checkbox" name="words" value="think"> Think | |
</label> | |
<label for="Write"> | |
<input type="checkbox" name="words" value="write"> Write | |
</label> | |
</div> | |
<div id="grammarEntities"> | |
<h3>Grammar Entities</h3> | |
<select name="grammarEntities" id="grammarEntitiesSelect" required> | |
<option value="">Select a Grammar Entity</option> | |
<option value="adjective">Adjective</option> | |
<option value="noun">Noun</option> | |
<option value="verb">Verb</option> | |
</select> | |
</div> | |
<div id="assignButton"> | |
<input type="submit" value="Assign"> | |
</div> | |
</form> | |
<div class="assignedGrammarEntities"> | |
<h2>Assigned Grammar Entities</h2> | |
<h3>Adjective</h3> | |
<div id="adjectiveEntity"></div> | |
<h3>Noun</h3> | |
<div id="nounEntity"></div> | |
<h3>Verb</h3> | |
<div id="verbEntity"></div> | |
</div> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> | |
<script> | |
$(document).ready(function() { | |
$('#wordAssignmentForm').submit(function(event) { | |
event.preventDefault(); | |
let checkedWords = []; | |
$.each($("input[name='words']:checked"), function(){ | |
checkedWords.push($(this).val()); | |
}); | |
$('#' + $('#grammarEntitiesSelect').val() + 'Entity').html( checkedWords.join(', ')); | |
}); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment