Advertisement
cqmikko

Custom script disabling radio buttons

Mar 3rd, 2016
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. function disable_Options(c) {
  2.  
  3. // Get the list of radio options with class name form-radio
  4. var radio = document.getElementsByClassName("form-radio");
  5.  
  6. // Check each class name radio button
  7. for(var i = 0; i < radio.length; i++) {
  8.  
  9.  
  10. //Set what specific conditions if an option is selected and list the ones that will be disabled.
  11. // radio[0] is selected then disable radio[1]
  12. if(radio[0].checked) {
  13.  
  14. radio[1].disabled = true;
  15. radio[1].parentNode.style.opacity = "0.7";
  16.  
  17.  
  18. }
  19.  
  20. // if radio [2] is selected then disable radio[3]
  21. else if(radio[2].checked) {
  22. radio[3].disabled = true;
  23. radio[3].parentNode.style.opacity = "0.7";
  24.  
  25. }
  26.  
  27.  
  28. radio[i].disabled = false;
  29. radio[i].parentNode.style.opacity = "1";
  30.  
  31.  
  32. }
  33.  
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement