Created
August 15, 2010 07:47
-
-
Save georgeredinger/525227 to your computer and use it in GitHub Desktop.
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> | |
<script type="text/javascript" src="/jquery-1.4.2.min.js"></script> | |
<title>Pickle Jar</title> | |
</head> | |
<body bgcolor=green > | |
<h1> Spokane Ruby Brigade </h1> | |
<h2> Pickle Jar </h2> | |
<p> Enter a comma separated list of names, eg. bob,joe,alice,frank</p> | |
<form> | |
<div> | |
<label for="names">Contestants: </label> | |
<input type="text" id="names" name="names" size="84"> | |
</div> | |
</form> | |
<div> | |
<br/> | |
<center><button type="button" id="choose"> choose </button></center> | |
</div> | |
<div id='winner'></div> | |
<script type="text/javascript"> | |
$( init ); | |
function init() { | |
$('#choose').bind( 'click', choose ); | |
} | |
function choose() { | |
var names = $("input#names").val(); | |
var namesa = names.split(","); | |
var winner_index=Math.floor(Math.random()*(namesa.length)); | |
var list = "<p>After carefully considering all "+namesa.length+" candidates:</p><ol>"; | |
for (i in namesa) list = list + "<li>" + namesa[i] + "</li>"; | |
list = list + "</ol>"; | |
$("#winner").html('<h3> The winner is:</h3><h1><FONT COLOR="RED"> '+namesa[winner_index]+"</font></h1>"+list); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment