-
-
Save diegorv/125428 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<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 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 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