I started a survey last year not realizing that when you reload a drilldown question with an edited list, it will RECODE all of your values. I have about 60 program specific reports that I am basing off of the value of these codes. Since I plan to use this program monthly for a few years I accepted just updating the filters but unexpectedly I have more changes to the drilldown. To avoid hours of redoing saved filter I am trying to hard code the drill down. I am having decent success but when I click the next button my program name and program number get wiped out of the input. If you can provide any help with how to prevent that from happening I’d appreciate it.
Otherwise I have a work around where I save the program number in the Embedded data and base my filters on Embedded data instead of Question data. That is okay but it takes some working and fingers crossing to get this set up BEFORE having data that chose a particular program number - a requirement as I am showing people their cumulative responses live through an advanced report.
I am not the strongest programmer and this is definitely brute force programmed. Some providers have multiple programs but each program will only have one program number.
Qualtrics.SurveyEngine.addOnload(function()
{
/*Place your JavaScript here to run when the page loads*/
});
Qualtrics.SurveyEngine.addOnReady(function() {
/*Place your JavaScript here to run when the page is fully displayed*/
var that = this.questionId;
//Add options that should be in the drop down list s1 = first in the list, s2 = second in the list, sn = nth in the list...
var element = (
"<select id='s1'><option ></option><option value='1'>Anesis Center for Marriage and Family Therapy LLC</option><option value='2'>Bayview Foundation Inc</option>" +
"<option value='3'>Big Brothers and Big Sisters of Dane County Inc</option><option value = '4'>Cambridge Community Activities Program</option>" +
"<option value='5'>Catholic Multicultural Center</option><option value='6'>Centro Hispano</option>" +
"<option value='7'>CEOs of Tomorrow Inc</option><option value='8'>Chlildren's Service Society of WI</option>" +
"<option value='9'>City of Fitchburg</option><option value='10'>City of Middleton</option>" +
"<option value='11'>City of Stoughton</option><option value='12'>City of Sun Prairie</option>" +
"<option value='13'>DCDHS - Adult Protective Services</option><option value='14'>Deerfield Community Center</option>" +
"<option value='15'>Domestic Abuse Intervention Services</option><option value='16'>Families Back To The Table Inc</option>" +
"<option value='17'>Family Service Madison</option><option value='18'>Goodman Community Center, Inc.</option>" +
"<option value='19'>Jewish Social Services of Madison Inc</option><option value='20'>Lussier Community Education Center</option>" +
"<option value='21'>Lutheran Social Services</option><option value='22'>Madison Metropolitan School District</option>" +
"<option value='37'>Madison Reading Project</option><option value='23'>McFarland Youth Center, Inc.</option><option value='24'>Mount Zion Batist Church</option>" +
"<option value='25'>Oregon Youth Center Inc</option><option value='26'>Outreach</option>" +
"<option value='27'>Planned Parenthood of WI</option><option value='28'>Porchligth Inc</option>" +
"<option value='29'>Rape Crisis Center</option><option value='30'>Today Not Tomorrow</option>" +
"<option value='31'>United Way of Dane County</option><option value='32'>Urban League of Greater Madison</option>" +
"<option value='33'>Vivent Health, Inc. fka Aids Resource Center of WI</option><option value='34'>Wisconsin Youth Company, Inc.</option>" +
"<option value='35'>YWCA Madison Inc</option><option value='36'>Test Provider</option></select>"
);
var element2 = "<select id='s2'><option ></option></select>";
var element3 = "<select id='s3'><option ></option></select>";
//show select list after row number _ label
jQuery(element).insertAfter("#" + that + " .InputText:eq(0)");
jQuery(element2).insertAfter("#" + that + " .InputText:eq(1)");
jQuery(element3).insertAfter("#" + that + " .InputText:eq(2)");
//hide input fields
jQuery("#" + that + " .InputText:eq(0)").hide();
jQuery("#" + that + " .InputText:eq(1)").hide();
jQuery("#" + that + " .InputText:eq(2)").hide();
//upon first selection, display the text value and not the code
jQuery("#" + that + " .InputText:eq(0)").val(jQuery("#s1 option:selected").text());
jQuery("#" + that + " .InputText:eq(1)").val(jQuery("#s2 option:selected").text());
jQuery("#" + that + " .InputText:eq(2)").val(jQuery("#s3 option:selected").text());
jQuery("#s1").on('change', function() {
jQuery("#" + that + " .InputText:eq(0)").val(jQuery("#s1 option:selected").text());
var provider = jQuery("#" + that + " .InputText:eq(0)").val();
console.log("provider "+provider);
//If provider is Anesis
if(provider == 'Anesis Center for Marriage and Family Therapy LLC') {
var element2 = "<select id='s2'><option</option><option value='1'>Outreach</option></select>";
var element3 = "<select id='s3'><option</option><option value='13366'>13366</option></select>";
}
//If provider is Bayview
if(provider == 'Bayview Foundation Inc') {
var element2 = "<select id='s2'><option</option><option value='2'>Behavioral Health Support & Referral</option></select>";
var element3 = "<select id='s3'><option</option><option value='13339'>13339</option></select>";
}
//If provider is Big Brother Big Sister
if(provider == 'Big Brothers and Big Sisters of Dane County Inc') {
var element2 = "<select id='s2'><option</option><option value='3'>Youth Mentoring Services</option></select>";
var element3 = "<select id='s3'><option</option><option value='13380'>13380</option></select>";
}
//If provider is Cambridge Community
if(provider == 'Cambridge Community Activities Program') {
var element2 = "<select id='s2'><option</option><option value='4'>Cambridge Youth Resource Center</option></select>";
var element3 = "<select id='s3'><option</option><option value='4609'>4609</option></select>";
}
//If provider is Catholic Multicultural
if(provider == 'Catholic Multicultural Center') {
var element2 = "<select id='s2'><option </option><option value='5'>Afhan Refugee Assistance</option><option value='6'>Immigration Services</option></select>";
var element3 = "<select id='s3'><option </option></select>";
}
//If provider is Centro
if(provider == 'Centro Hispano') {
var element2 = "<select id='s2'><option </option><option value='7'>Accredited Representative</option><option value='8'>Community Engagement</option>" +
"<option value='9'>Immigration Assistance</option><option value='10'>Juventud/Escalera</option><option value='11'>Pro Se Clinics</option></select>";
var element3 = "<select id='s3'><option </option></select>";
}
//If provider is CEOs of Tomorrow
if(provider == 'CEOs of Tomorrow Inc') {
var element2 = "<select id='s2'><option</option><option value='12'>YJIG - Social Entreprenuership</option></select>";
var element3 = "<select id='s3'><option</option><option value='12654'>12654</option></select>";
}
//If provider is Children's Service
if(provider == "Chlildren's Service Society of WI") {
var element2 = "<select id='s2'><option </option><option value='13'>Empl & Education Specialist - Allied</option><option value='14'>Empl & Education Specialist - Leopold</option>" +
"<option value='15'>Empl & Education Specialist - Northside</option><option value='16'>Empl & Education Specialist - Russett</option><option value='17'>Empl & Education Specialist - Sun Prairie</option></select>";
var element3 = "<select id='s3'><option </option></select>";
}
//If provider is Fitchburg
if(provider == 'City of Fitchburg') {
var element2 = "<select id='s2'><option</option><option value='18'>Neighborhood Navigators</option></select>";
var element3 = "<select id='s3'><option</option><option value='12599'>12599</option></select>";
}
//If provider is Middleton
if(provider == 'City of Middleton') {
var element2 = "<select id='s2'><option</option><option value='19'>Middleton Youth Center</option></select>";
var element3 = "<select id='s3'><option</option><option value='10553'>10553</option></select>";
}
//If provider is Stoughton
if(provider == 'City of Stoughton') {
var element2 = "<select id='s2'><option</option><option value='19'>Stoughton YRC</option></select>";
var element3 = "<select id='s3'><option</option><option value='4458'>4458</option></select>";
}
//If provider is Sun Prairie
if(provider == 'City of Sun Prairie') {
var element2 = "<select id='s2'><option </option><option value='21'>Neighborhood Navigators</option><option value='22'>Youth Mentorship Program</option></select>";
var element3 = "<select id='s3'><option </option></select>";
}
//If provider is DCDHS - APS
if(provider == 'DCDHS - Adult Protective Services') {
var element2 = "<select id='s2'><option </option><option value='23'>Elders at Risk (18-59)</option><option value='24'>Elders at Risk (60+)</option></select>";
var element3 = "<select id='s3'><option </option></select>";
}
//If provider is Deerfield
if(provider == 'Deerfield Community Center') {
var element2 = "<select id='s2'><option </option><option value='25'>Behavioral Health Support & Referral</option><option value='26'>Deerfield Youth Center</option></select>";
var element3 = "<select id='s3'><option </option></select>";
}
//If provider is DIAS
if(provider == 'Domestic Abuse Intervention Services') {
var element2 = "<select id='s2'><option </option><option value='27'>Crisis Case Management</option>" +
"<option value='28'>Crisis Intervention</option><option value='29'>Legal Services</option></select>";
var element3 = "<select id='s3'><option </option></select>";
}
//If provider is Families Back
if(provider == 'Families Back To The Table Inc') {
var element2 = "<select id='s2'><option</option><option value='30'>Family Engagement</option></select>";
var element3 = "<select id='s3'><option</option><option value='13712'>13712</option></select>";
}
//If provider is Family Service Madison
if(provider == 'Family Service Madison') {
var element2 = "<select id='s2'><option </option><option value='31'>AODA Prevention</option>" +
"<option value='32'>Community Mobilization</option></select>";
var element3 = "<select id='s3'><option </option></select>";
}
//If provider is Goodman
if(provider == 'Goodman Community Center, Inc.') {
var element2 = "<select id='s2'><option </option><option value='33'>Basketball & Recreation Services</option>" +
"<option value='32'>Goodman Youth Resource Center</option></select>";
var element3 = "<select id='s3'><option </option></select>";
}
//If provider is JSS
if(provider == 'Jewish Social Services of Madison Inc') {
var element2 = "<select id='s2'><option </option><option value='35'>Afghan Refugee Assistance</option>" +
"<option value='36'>Immigration Services</option></select>";
var element3 = "<select id='s3'><option </option></select>";
}
//If provider is Lussier
if(provider == 'Lussier Community Education Center') {
var element2 = "<select id='s2'><option</option><option value='37'>Youth Resource Center</option></select>";
var element3 = "<select id='s3'><option</option><option value='1953'>1953</option></select>";
}
//If provider is LSS
if(provider == 'Lutheran Social Services') {
var element2 = "<select id='s2'><option</option><option value='38'>Off The Square Club</option></select>";
var element3 = "<select id='s3'><option</option><option value='1320'>1320</option></select>";
}
//If provider is MMSD
if(provider == 'Madison Metropolitan School District') {
var element2 = "<select id='s2'><option</option><option value='39'>Youth Resource Centers</option></select>";
var element3 = "<select id='s3'><option</option><option value='1896'>1896</option></select>";
}
//If provider is Madison Reading Project
if(provider == 'Madison Reading Project') {
var element2 = "<select id='s2'><option</option><option value='59'>My First Pages</option></select>";
var element3 = "<select id='s3'><option</option><option value='14474'>14474</option></select>";
}
//If provider is McFarland YC
if(provider == 'McFarland Youth Center, Inc.') {
var element2 = "<select id='s2'><option</option><option value='40'>Youth Resource Center</option></select>";
var element3 = "<select id='s3'><option</option><option value='14474'>14474</option></select>";
}
//If provider is Mt Zion Baptist
if(provider == 'Mount Zion Batist Church') {
var element2 = "<select id='s2'><option</option><option value='41'>Mentoring & Prevention Pilot Program</option></select>";
var element3 = "<select id='s3'><option</option><option value='13414'>13414</option></select>";
}
//If provider is Oregon YC
if(provider == 'Oregon Youth Center Inc') {
var element2 = "<select id='s2'><option</option><option value='42'>Oregon Youth Center</option></select>";
var element3 = "<select id='s3'><option</option><option value='11169'>11169</option></select>";
}
//If provider is Outreach
if(provider == 'Outreach') {
var element2 = "<select id='s2'><option </option><option value='43'>Information/Referral</option>" +
"<option value='44'>Outreach</option><option value='45'>Senior LGBT Outreach</option>" +
"<option value='46'>Transgender Health Advocate</option></select>";
var element3 = "<select id='s3'><option </option></select>";
}
//If provider is Planned Parenthood
if(provider == 'Planned Parenthood of WI') {
var element2 = "<select id='s2'><option</option><option value='47'>Family Planning</option></select>";
var element3 = "<select id='s3'><option</option><option value='4415'>4415</option></select>";
}
//If provider is Porchlight
if(provider == 'Porchligth Inc') {
var element2 = "<select id='s2'><option</option><option value='48'>Safehaven - Outreach</option></select>";
var element3 = "<select id='s3'><option</option><option value='13358'>13358</option></select>";
}
//If provider is RCC
if(provider == 'Rape Crisis Center') {
var element2 = "<select id='s2'><option </option><option value='49'>Crisis Intervention</option>" +
"<option value='50'>Sexual Assault Prevention Services</option></select>";
var element3 = "<select id='s3'><option </option></select>";
}
//If provider is Today Not Tomorrow
if(provider == 'Today Not Tomorrow') {
var element2 = "<select id='s2'><option</option><option value='51'>Family Resource Center</option></select>";
var element3 = "<select id='s3'><option</option><option value='12519'>12519</option></select>";
}
//If provider is Unitedway
if(provider == 'United Way of Dane County') {
var element2 = "<select id='s2'><option</option><option value='52'>Sun Prairie ECZ Housing Assistance</option></select>";
var element3 = "<select id='s3'><option</option><option value='13569'>13569</option></select>";
}
//If provider is Urban League
if(provider == 'Urban League of Greater Madison') {
var element2 = "<select id='s2'><option</option><option value='53'>21st Century Careers</option></select>";
var element3 = "<select id='s3'><option</option><option value='4590'>4590</option></select>";
}
//If provider is Vivent
if(provider == 'Vivent Health, Inc. fka Aids Resource Center of WI') {
var element2 = "<select id='s2'><option</option><option value='54'>Intake and Needle Exchange</option></select>";
var element3 = "<select id='s3'><option</option><option value='13358'>13358</option></select>";
}
//If provider is WI Youth Co
if(provider == 'Wisconsin Youth Company, Inc.') {
var element2 = "<select id='s2'><option</option><option value='55'>Wisconsin Youth & Family Center</option></select>";
var element3 = "<select id='s3'><option</option><option value='4507'>4507</option></select>";
}
//If provider is YWCA
if(provider == 'YWCA Madison Inc') {
var element2 = "<select id='s2'><option</option><option value='56'>M. School Restorative Justice</option></select>";
var element3 = "<select id='s3'><option</option><option value='10935'>10935</option></select>";
}
//If provider is Test Provider
if(provider == 'Test Provider') {
var element2 = "<select id='s2'><option </option><option value='57'>Betsy</option>" +
"<option value='58'>Michele</option></select>";
var element3 = "<select id='s3'><option </option></select>";
}
jQuery("#s2").hide();
jQuery(element2).insertAfter("#" + that + " .InputText:eq(1)");
jQuery("#" + that + " .InputText:eq(1)").val(jQuery("#s2 option:selected").text());
jQuery("#s3").hide();
jQuery(element3).insertAfter("#" + that + " .InputText:eq(2)");
jQuery("#" + that + " .InputText:eq(2)").val(jQuery("#s3 option:selected").text());
jQuery("#" + that + " .InputText:eq(1)").val(jQuery("#s2 option:selected").text());
var program = jQuery("#" + that + " .InputText:eq(1)").val();
jQuery("#s2").on('change', function() {
jQuery("#" + that + " .InputText:eq(1)").val(jQuery("#s2 option:selected").text());
var program = jQuery("#" + that + " .InputText:eq(1)").val();
jQuery("#" + that + " .InputText:eq(2)").val(jQuery("#s3 option:selected").text());
///////////// Catholic Multicultural Center //////////////////
//If program is Afhan Refugee
if(provider=='Catholic Multicultural Center' && program == 'Afhan Refugee Assistance') {
var element3 = "<select id='s3'><option</option><option value='13557'>13557</option></select>";
}
//If program is Immigration
if(provider=='Catholic Multicultural Center' && program == 'Immigration Services') {
var element3 = "<select id='s3'><option</option><option value='13151'>13151</option></select>";
}
///////////// CENTRO HISPANO //////////////////////
//If program is Accred Rep
if(provider=='Centro Hispano' && program == 'Accredited Representative') {
var element3 = "<select id='s3'><option</option><option value='12712'>12712</option></select>";
}
//If program is Comm Engage
if(provider=='Centro Hispano' && program == 'Community Engagement') {
var element3 = "<select id='s3'><option</option><option value='11969'>11969</option></select>";
}
//If program is Immigration Assistance
if(provider=='Centro Hispano' && program == 'Immigration Assistance') {
var element3 = "<select id='s3'><option</option><option value='13120'>13120</option></select>";
}
//If program is Juventud/Escalera
if(provider=='Centro Hispano' && program == 'Juventud/Escalera') {
var element3 = "<select id='s3'><option</option><option value='1490'>1490</option></select>";
}
//If program is Pro Se Clinic
if(provider=='Centro Hispano' && program == 'Pro Se Clinics') {
var element3 = "<select id='s3'><option</option><option value='13602'>13602</option></select>";
}
///////////// Chlildren's Sevice //////////////////////
//If program is Allied
if(provider=="Chlildren's Service Society of WI" && program == 'Empl & Education Specialist - Allied') {
var element3 = "<select id='s3'><option</option><option value='4559'>4559</option></select>";
}
//If program is Leopold
if(provider=="Chlildren's Service Society of WI" && program == 'Empl & Education Specialist - Leopold') {
var element3 = "<select id='s3'><option</option><option value='12639'>12639</option></select>";
}
//If program is Northside
if(provider=="Chlildren's Service Society of WI" && program == 'Empl & Education Specialist - Northside') {
var element3 = "<select id='s3'><option</option><option value='12640'>12640</option></select>";
}
//If program is Russett
if(provider=="Chlildren's Service Society of WI" && program == 'Empl & Education Specialist - Russett') {
var element3 = "<select id='s3'><option</option><option value='12642'>12642</option></select>";
}
//If program is Sun Prairie
if(provider=="Chlildren's Service Society of WI" && program == 'Empl & Education Specialist - Sun Prairie') {
var element3 = "<select id='s3'><option</option><option value='12641'>12641</option></select>";
}
///////////// CITY OF SUN PRAIRIE //////////////////
//If program is Navigators
if(provider=='City of Sun Prairie' && program == 'Neighborhood Navigators') {
var element3 = "<select id='s3'><option</option><option value='12600'>12600</option></select>";
}
//If program is Youth Mentorship
if(provider=='City of Sun Prairie' && program == 'Youth Mentorship Program') {
var element3 = "<select id='s3'><option</option><option value='13310'>13310</option></select>";
}
///////////// DCDHS - APS //////////////////
//If program is 18-59
if(provider=='DCDHS - Adult Protective Services' && program == 'Elders at Risk (18-59)') {
var element3 = "<select id='s3'><option</option><option value='12919'>12919</option></select>";
}
//If program is 60+
if(provider=='DCDHS - Adult Protective Services' && program == 'Elders at Risk (60+)') {
var element3 = "<select id='s3'><option</option><option value='12918'>12918</option></select>";
}
///////////// DEERFIELD //////////////////
//If program is Behavioral Health
if(provider=='Deerfield Community Center' && program == 'Behavioral Health Support & Referral') {
var element3 = "<select id='s3'><option</option><option value='13338'>13338</option></select>";
}
//If program is Youth Center
if(provider=='Deerfield Community Center' && program == 'Deerfield Youth Center') {
var element3 = "<select id='s3'><option</option><option value='12880'>12880</option></select>";
}
///////////// DIAS //////////////////
//If program is Crisis Case Management
if(provider=='Domestic Abuse Intervention Services' && program == 'Crisis Case Management') {
var element3 = "<select id='s3'><option</option><option value='13726'>13726</option></select>";
}
//If program is Crisis Intervention
if(provider=='Domestic Abuse Intervention Services' && program == 'Crisis Intervention') {
var element3 = "<select id='s3'><option</option><option value='13724'>13724</option></select>";
}
//If program is Legal Services
if(provider=='Domestic Abuse Intervention Services' && program == 'Legal Services') {
var element3 = "<select id='s3'><option</option><option value='13725'>13725</option></select>";
}
///////////// FAMILY SERVICE MADISON //////////////////
//If program is AODA
if(provider=='Family Service Madison' && program == 'AODA Prevention') {
var element3 = "<select id='s3'><option</option><option value='13737'>13737</option></select>";
}
//If program is Community Mobilization
if(provider=='Family Service Madison' && program == 'Community Mobilization') {
var element3 = "<select id='s3'><option</option><option value='13738'>13738</option></select>";
}
//////////// GOODMAN //////////////////
//If program is Basketball
if(provider=='Goodman Community Center, Inc.' && program == 'Basketball & Recreation Services') {
var element3 = "<select id='s3'><option</option><option value='13112'>13112</option></select>";
}
//If program is Youth Center
if(provider=='Goodman Community Center, Inc.' && program == 'Goodman Youth Resource Center') {
var element3 = "<select id='s3'><option</option><option value='4397'>4397</option></select>";
}
//////////// JSS //////////////////
//If program is Afghan Refugees
if(provider=='Jewish Social Services of Madison Inc' && program == 'Afghan Refugee Assistance') {
var element3 = "<select id='s3'><option</option><option value='13112'>13112</option></select>";
}
//If program is Immigration
if(provider=='Jewish Social Services of Madison Inc' && program == 'Immigration Services') {
var element3 = "<select id='s3'><option</option><option value='4397'>4397</option></select>";
}
//////////// OUTREACH //////////////////
//If program is Info/Referral
if(provider=='Outreach' && program == 'Information/Referral') {
var element3 = "<select id='s3'><option</option><option value='13720'>13720</option></select>";
}
//If program is Outreach
if(provider=='Outreach' && program == 'Outreach') {
var element3 = "<select id='s3'><option</option><option value='13719'>13719</option></select>";
}
//If program is Senior LGBT
if(provider=='Outreach' && program == 'Senior LGBT Outreach') {
var element3 = "<select id='s3'><option</option><option value='11036'>11036</option></select>";
}
//If program is Transgender
if(provider=='Outreach' && program == 'Transgender Health Advocate') {
var element3 = "<select id='s3'><option</option><option value='12738'>12738</option></select>";
}
///////////// RCC //////////////////
//If program is Crisis Intervention
if(provider=='Rape Crisis Center' && program == 'Crisis Intervention') {
var element3 = "<select id='s3'><option</option><option value='1283'>1283</option></select>";
}
//If program is Sexual Assault
if(provider=='Rape Crisis Center' && program == 'Sexual Assault Prevention Services') {
var element3 = "<select id='s3'><option</option><option value='12548'>12548</option></select>";
}
///////////// TEST PROVIDER //////////////////
//If program is Betsy
if(provider=='Test Provider' && program == 'Betsy') {
var element3 = "<select id='s3'><option</option><option value='99999'>99999</option></select>";
}
//If program is Michele
if(provider=='Test Provider' && program == 'Michele') {
var element3 = "<select id='s3'><option</option><option value='99998'>99998</option></select>";
}
jQuery("#s3").hide();
jQuery(element3).insertAfter("#" + that + " .InputText:eq(2)");
jQuery("#" + that + " .InputText:eq(2)").val(jQuery("#s3 option:selected").text());
});
var prgmnum = jQuery("#" + that + " .InputText:eq(2)").val(jQuery("#s3 option:selected").text());
Qualtrics.SurveyEngine.setEmbeddedData("ProgramNo", prgmnum);
Qualtrics.SurveyEngine.setEmbeddedData("Program",program);
Qualtrics.SurveyEngine.setEmbeddedData("Provider",provider);
console.log("outter: program ", program, " provider ", provider, " program number ",prgmnum);
});
});
Qualtrics.SurveyEngine.addOnUnload(function()
{
/*Place your JavaScript here to run when the page is unloaded*/
});