Created
June 18, 2009 18:58
-
-
Save anonymous/132124 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>:: jQuery ::</title> | |
| <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> | |
| </head> | |
| </style> | |
| <body> | |
| <form name="listForm" id="listForm"> | |
| <input type="checkbox" name="choice" value="2" />2<br/> | |
| <input type="checkbox" name="choice" value="5" />5<br/> | |
| <input type="checkbox" name="choice" value="10" />10<br/> | |
| <input type="checkbox" name="choice" value="20" />20<br/> | |
| Total: <input type="text" size="2" name="total" id="total" value="0"/> | |
| </form> | |
| </body> | |
| <script language="JavaScript" type="text/javascript" src="jquery/jquery-1.3.2.min.js"></script> | |
| <script> | |
| $(function(){ | |
| total = document.getElementById('total'); | |
| $(document.getElementsByName('choice')).bind('click',function(){ | |
| var valTotal = parseInt(total.value),valInput = parseInt(this.value),novoTotal=0; | |
| total.value = (this.checked) ? ( valTotal + valInput ) : ( valTotal - valInput ) ; | |
| }); | |
| }); | |
| </script> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment