Skip to content

Instantly share code, notes, and snippets.

@iruslani
Created June 1, 2012 22:30
Show Gist options
  • Save iruslani/2855503 to your computer and use it in GitHub Desktop.
Save iruslani/2855503 to your computer and use it in GitHub Desktop.
Change the url of the button depending if the checkbox is checked.
<html>
<head></head>
<body>
<!-- This checkbox is checked and cannot be unchecked -->
<input type="checkbox" name="fw" id="freefw" checked disabled />
<!-- If this checkbox changes, see jquery below -->
<input type="checkbox" name="av" id="freeavfw" />
<a id="download" href="what/link/do/we/use">
<img src="http://download.zonealarm.com/bin/images/cfu/yellow_freeupdate_btn.png" />
</a>
</body>
<script>
$('#freeavfw').change(function(){
// jquery shorthand conditioning statement. If true use link1 if not use link2.
var c = this.checked ? 'link1' : 'link2';
// change the href attribute for the element ID = download to the value stored in 'c'.
$('#download').attr("href", c);
});
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment