Skip to content

Instantly share code, notes, and snippets.

@gvinter
Created June 21, 2011 00:09
Show Gist options
  • Save gvinter/1036932 to your computer and use it in GitHub Desktop.
Save gvinter/1036932 to your computer and use it in GitHub Desktop.
Javascript Form
<form>
Name: <Input type="textbox" name="name" /> <br />
Check box if you're alive: <Input type="checkbox" name="alive" /> <br />
<Input type="submit" name="submit" value="we win click!" onClick="pulse(form)" />
</form>
<script type="text/javascript">
function pulse(data){
console.log(data);
var isAlive = document.form.getElementByName(alive).checked;
var name = document.form.getElementByName(name).value;
if (isAlive)
{
alert("Thank goodness you're alive," + name);
}
else
{
alert("Oh, no!" + name + "Don't die!");
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment