Skip to content

Instantly share code, notes, and snippets.

Created June 7, 2009 18:41
Show Gist options
  • Save anonymous/125427 to your computer and use it in GitHub Desktop.
Save anonymous/125427 to your computer and use it in GitHub Desktop.
<html>
<head>
<title></title>
<META NAME="DESCRIPTION" CONTENT="">
<META NAME="KEYWORDS" CONTENT="">
<script type="text/javascript" src="jquery-1.3.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var total1 = 0;
var total2 = 0;
$(".butao").click(function(event){
var opcoes = 7;
var limite = 2;
var id = $(this).attr("value");
window['ckb' + id] = $(this).attr("checked");
if (total1 < limite) {
total1 = total1 + 1;
}
else {
if (!window['ckb'+ id]) {
total1 = total - 1;
}
else {
alert("Voce pode escolher ate: " + limite + " opcoes.");
$(this).attr("checked","false");
return false;
}
}
});
$(".butao2").click(function(event){
var opcoes = 10;
var limite = 3;
var id = $(this).attr("value");
window['ckb2' + id] = $(this).attr("checked");
if (total2 < limite) {
total2 = total2 + 1;
}
else {
if (!window['ckb2' + id]) {
total2 = total - 1;
}
else {
alert("Voce pode escolher ate: " + limite + " opcoes.");
$(this).attr("checked","false");
return false;
}
}
});
});
</script>
</head>
<form name='form1' method='post' action='teste.php'>
<input type=checkbox name=ckb[1] value=1 class="butao">PHP
<input type=checkbox name=ckb[2] value=2 class="butao">Perl
<input type=checkbox name=ckb[3] value=3 class="butao">MySQL
<input type=checkbox name=ckb[4] value=4 class="butao">ASP
<input type=checkbox name=ckb[5] value=5 class="butao">JavaScript
<input type=checkbox name=ckb[6] value=6 class="butao">HTML
<input type=checkbox name=ckb[7] value=7 class="butao">Photo Shop
<label>
<input type="submit" name="button" id="button" value="Submit">
</label>
</form>
<hr>
<form name='form1' method='post' action='teste.php'>
<input type=checkbox name=ckb2[1] value=1 class="butao2">Coca-Cola
<input type=checkbox name=ckb2[2] value=2 class="butao2">Fanta
<input type=checkbox name=ckb2[3] value=3 class="butao2">Sprite
<input type=checkbox name=ckb2[4] value=4 class="butao2">Guarana
<input type=checkbox name=ckb2[5] value=5 class="butao2">H2OH
<input type=checkbox name=ckb2[6] value=6 class="butao2">Cerveja Bavaria
<input type=checkbox name=ckb2[7] value=7 class="butao2">Agua
<input type=checkbox name=ckb2[8] value=8 class="butao2">Suco de limão
<input type=checkbox name=ckb2[9] value=9 class="butao2">Pepsi
<input type=checkbox name=ckb2[10] value=10 class="butao2">Suco de laranja
<label>
<input type="submit" name="button" id="button" value="Submit">
</label>
</form>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment