daily pastebin goal
10%
SHARE
TWEET

Untitled

a guest Jul 11th, 2018 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script src="http://code.jquery.com/jquery-1.10.2.min.js" type="text/javascript"></script>
  2. <script language="javascript" type="text/javascript">
  3. /**
  4. if F01-a is No
  5.     then F01-b , F01-c & F01-d either don’t show or are forced to N/A
  6. only if question F01-b is No
  7.     then F01-c & F01-d don’t show or are forced to N/A
  8. only if question F01-c is No then F01-d don’t show or is forced to N/A only
  9. **/
  10. $(document).ready(function(){
  11.     $("select[title^='F01'").change(function(){
  12.         var title = $(this).attr("title");
  13.         var selected = $(this).find("option:selected").text();
  14.         if(title == "F01-a" && selected == "No") {
  15.             //set F01-b , F01-c & F01-d to N/A
  16.             $("select[title='F01-b']").val("N/A");
  17.             $("select[title='F01-c']").val("N/A");
  18.             $("select[title='F01-d']").val("N/A");
  19.             //hide F01-b , F01-c & F01-d
  20.             $("select[title='F01-b']").hide();
  21.             $("select[title='F01-c']").hide();
  22.             $("select[title='F01-d']").hide();
  23.             // or set F01-b , F01-c & F01-d read-only
  24.             //$("select[title='F01-b']").prop("disabled", "disabled");
  25.             //$("select[title='F01-c']").prop("disabled", "disabled");
  26.             //$("select[title='F01-d']").prop("disabled", "disabled");
  27.         }else if (title == "F01-b" && selected == "No"){
  28.             //set F01-c & F01-d to N/A
  29.             $("select[title='F01-c']").val("N/A");
  30.             $("select[title='F01-d']").val("N/A");
  31.             //hide F01-c & F01-d
  32.             $("select[title='F01-c']").hide();
  33.             $("select[title='F01-d']").hide();
  34.             // or set F01-c & F01-d read-only
  35.             //$("select[title='F01-c']").prop("disabled", "disabled");
  36.             //$("select[title='F01-d']").prop("disabled", "disabled");
  37.         }else if (title == "F01-c" && selected == "No"){
  38.             //set F01-d to N/A
  39.             $("select[title='F01-d']").val("N/A");
  40.             //hide F01-d
  41.             $("select[title='F01-d']").hide();
  42.             // or set F01-d read-only
  43.             //$("select[title='F01-d']").prop("disabled", "disabled");
  44.         }else{
  45.             //enable F01-b F01-c & F01-d
  46.             $("select[title='F01-b']").show()
  47.             $("select[title='F01-c']").show();
  48.             $("select[title='F01-d']").show();
  49.             //$("select[title='F01-b']").prop("disabled", "");
  50.             //$("select[title='F01-c']").prop("disabled", "");
  51.             //$("select[title='F01-d']").prop("disabled", "");
  52.         }
  53.     });
  54. });
  55. </script>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top