Election Quiz

Test for MAJ.

by the_voder

HTML

<form id="quiz" action="">
	<ol>
		<li>
            <p>
                Do you have a background in Financial Services?<br />
                <label><input name="q1" type="radio" value="yes" data-party="ukip" />Yes</label><br />
			    <label><input name="q1" type="radio" value="no" data-party="torie" />No</label><br />
            </p>
		</li>
		<li>
			<p>
                Is your favourite colour blue?<br />
                <label><input name="q2" type="radio" value="yes" data-party="torie"  />Yes</label><br />
                <label><input name="q2" type="radio" value="no" data-party="ukip" />No</label><br />
            </p>
		</li>
		<li>
			<p>
                Do you drink beer at every (photo) opportunity?<br />
                <label><input name="q3" type="radio" value="yes" data-party="ukip" />Yes</label><br />
                <label><input name="q3" type="radio" value="no" data-party="torie" />No</label><br />
            </p>
        </li>	
		<li>
			<p>
                Do you have a big, round, moon face?<br />
                <label><input name="q4" type="radio" value="yes" data-party="torie" />Yes</label><br />
                <label><input name="q4" type="radio" value="no" data-party="ukip" />No</label><br />
            </p>
		</li>
	</ol>
	<input type="submit" value="Tell me how to vote!" />	
</form>

<p id="quiz-diagnosis"></p>

<script type="text/javascript">// <![CDATA[
	// Feedback messages
	var feedback = {};
	feedback.answerallquestions = "Please answer all questions";
	feedback.ukip = "You are Nigel Farrage, vote UKIP";
	feedback.torie = "You are David Cameron, vote Conservative";
	feedback.inconclusive = "Your answers were inconclusive, vote Liberal Democrat";
	jQuery("#quiz").submit(function(e) {
		// Check all questions answered
		if(jQuery("#quiz ol li").length === jQuery("input[type='radio']:checked").length) {
			// Create array of answers
			var answers = [
				{
					party:
					'ukip', count:...