abajan

explanationOfScriptInForm_20838502053851

Mar 24th, 2012
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. <script type="text/javascript">
  2.  
  3. //Each checkbox (targeted by its ID) is placed into an appropriately named variable
  4. var product1 = document.getElementById("input_1_1001");
  5. var product2 = document.getElementById("input_1_1002");
  6. var product3 = document.getElementById("input_1_1003");
  7. var allProducts = document.getElementById("input_1_1004");
  8.  
  9. /* The following function is called by the onClick event in the "All Products Discounted" input tag.
  10. It can be interpreted as follows: If the "All Products Discounted" box is checked,
  11. the Product 1, Product 2 and Product 3 boxes become unchecked. ("0" is equivalent to "false") */
  12.  
  13. function uncheckOthers() {
  14. if (allProducts.checked) {
  15. product1.checked = 0;
  16. product2.checked = 0;
  17. product3.checked = 0;
  18. }
  19. }
  20.  
  21. /* The following function is called by the onClick event in the input tag of each of the first three checkboxes.
  22. It can be interpreted as follows: If Product 1 or Product 2 or Product 3 is checked, "All Products Discounted" becomes unchecked. */
  23.  
  24. function uncheckDiscount() {
  25. if (product1.checked || product2.checked || product3.checked) {
  26. allProducts.checked = 0;
  27. }
  28. }
  29.  
  30. </script>
Advertisement
Add Comment
Please, Sign In to add comment