Skip to content

Instantly share code, notes, and snippets.

@jafstar
Created January 4, 2012 18:55
Show Gist options
  • Save jafstar/1561456 to your computer and use it in GitHub Desktop.
Save jafstar/1561456 to your computer and use it in GitHub Desktop.
Fancy Radio Button
<html>
<head>
<title>Fancy Radio Button</title>
</head>
<body>
<form action='some.php'>
<label for="employed1" >Are you currently employed?</label>
<br />
<input type="radio" name="employed" value="1" onclick="showForm(this.name+'1'); hideForm(this.name+'0')" />Yes
<input type="radio" name="employed" value="0" onclick="showForm(this.name+'0'); hideForm(this.name+'1')" />No
<br />
<textarea name="employed1" class="textAreas" placeholder="where do you work" value="1" ></textarea>
<textarea name="employed0" class="textAreas" placeholder="where were you last employed and for how long" value="0"></textarea>
<br />
<input type="submit" name="submit" value="Send" />
</form>
<script type='text/javascript'>
//EXTRA FORM SHOW
function showForm(n){
$("textarea[name='"+n+"']").slideDown("fast");
};
//EXTRA FORM HIDE
function hideForm(n){
$("textarea[name='"+n+"']").slideUp("fast");
};
//READY
$(document).ready(function() {
$('.textAreas').hide();
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment