$(document).ready(function() { populateGrade1(); /* Grade 1 Change */ $('select#grade1').change(function() { selectedVal=$(this).val() populateGrade2(selectedVal); }); /* Grade 2 Change */ $('select#grade2').change(function() { selectedVal=$(this).val() populateGrade3(selectedVal); }); }); function populateGrade1() { var options=''; $("#grade1").children("option").remove(); for (i=0; i < gradesA.length; i++) { options=options+''; }  $("#grade1").html(options); resetGrade3(); } function populateGrade2(parent) { var options=''; var numOptions=0; $("#grade2").children("option").remove(); for (i=0; i < gradesB.length; i++) { if(gradesB[i][0]==parent) { numOptions++; options=options+''; } }  if(numOptions==0) { options=''; $("#grade2").html(options); $("#grade2").hide() $("#grade3").children("option").remove(); $("#grade3").html(options); $("#grade3").hide(); } else { $("#grade2").html(options); $("#grade2").show() resetGrade3(); } } function resetGrade3() { $("#grade3").children("option").remove(); $("#grade3").html(""); } function populateGrade3(parent) { var options=''; var numOptions=0; $("#grade3").children("option").remove(); for (i=0; i < gradesC.length; i++) { if(gradesC[i][0]==parent) { numOptions++; options=options+''; } }  if(numOptions==0) { options=''; $("#grade3").html(options); $("#grade3").hide(); } else { $("#grade3").show(); } $("#grade3").html(options); } gradesA=[ [1,"Doctor/Physician"],[2,"Other Healthcare Professional"],[3,"Student"],[4,"Public Health/Health Policy"],[5,"Industry"],[6,"Education"],[7,"Academic Researcher"],[8,"Press/Media"]]; gradesB=[ [1,1,"Primary Care (General/Family Practice)"],[1,2,"Secondary Care"],[1,3,"Academic Medicine"],[1,4,"Public Health"],[1,5,"Commercial/Private"],[1,6,"Executive Management"],[1,7,"Other"],[2,8,"Acupuncturist"],[2,9,"Administrator"],[2,10,"Audiologist"],[2,11,"Chiropractor"],[2,12,"Counsellor"],[2,13,"Dentist"],[2,14,"Dietician"],[2,15,"Emergency Care Practitioner"],[2,16,"Executive Management"],[2,17,"Herbalist"],[2,18,"Homeopath"],[2,19,"Occupational Therapist"],[2,20,"Osteopath"],[2,21,"Paramedic"],[2,22,"Physician's Assistant"],[2,23,"Physiotherapist"],[2,24,"Podiatrist"],[2,25,"Practice Manager"],[2,26,"Psychologist"],[2,27,"Psychotherapist"],[2,28,"Radiographer"],[2,29,"Social Worker"],[2,30,"Speech Therapist"],[2,31,"Technician"],[2,32,"Other"],[3,33,"Medical"],[4,34,"Administrator"],[4,35,"Commissioner"],[4,36,"Consultant"],[4,37,"Director"],[4,38,"Information Analyst"],[4,39,"Manager"],[4,40,"Other Practitioner"],[4,41,"Researcher"],[4,42,"Student"],[4,43,"Trainee"],[4,44,"Other"],[5,45,"Health Insurance"],[5,46,"Healthcare Provision/Medical Services"],[5,47,"Legal"],[5,48,"Pharmaceutical"],[5,49,"Other"],[6,50,"Teacher - Pre-University"],[6,51,"Teacher - Undergraduate"],[6,52,"Teacher - Postgraduate"],[6,53,"Continuous Professional Development"],[6,54,"Trainer"],[6,55,"Appraiser"],[6,56,"Administrator"],[6,57,"Other"]]; gradesC=[ [1,1,"Specialty Training (GP ST1)"],[1,2,"Specialty Training (GP ST2)"],[1,3,"Specialty Training (GP ST3)"],[1,4,"Training (Other)"],[1,5,"GP (Salaried/Non-Principal)/Locum"],[1,6,"GP (Principal/Partner)"],[1,7,"Other"],[2,8,"Foundation Year 1 (F1)"],[2,9,"Foundation Year 2 (F2)"],[2,10,"Specialty Training (CT1)"],[2,11,"Specialty Training (CT2)"],[2,12,"Specialty Training (CT3)"],[2,13,"Specialty Training (ST1)"],[2,14,"Specialty Training (ST2)"],[2,15,"Specialty Training (ST3)"],[2,16,"Specialty Training (ST4)"],[2,17,"Specialty Training (ST5)"],[2,18,"Specialty Training (ST6)"],[2,19,"Specialty Training (ST7)"],[2,20,"Specialist Training (Other)"],[2,21,"Career Grade (Other)"],[2,22,"Medical Officer"],[2,23,"Clinical Assistant"],[2,24,"Hospital Practitioner"],[2,25,"SASG"],[2,26,"Consultant"],[2,27,"Other"],[3,28,"Academic F1/F2"],[3,29,"Fellow"],[3,30,"Lecturer"],[3,31,"Senior Lecturer"],[3,32,"Professor"],[3,33,"Academic (Other)"],[3,34,"Other"],[6,35,"Clinical Director"],[6,36,"Medical Director"],[6,37,"Other"],[33,38,"Year 1"],[33,39,"Year 2"],[33,40,"Year 3"],[33,41,"Year 4"],[33,42,"Year 5"],[33,43,"Year 6"],[33,44,"Other"]];