$(document).on("knack-view-render." + "view_XXX", function(event, view, data) {
toggleOptions(295, false, ["a corporation", "an individual"])
//ToggleOptions = 295 is field_num, false means hide, [array of values to look for and hide]
// true to turn on, false to turn off
});
function toggleOptions(field_num, onoff, listOfValues){
listOfValues.forEach(function(value){
var option = $(`select[name=field_${field_num}]`).find("option[value=\"" + value + "\"]");
if(option.length === 0) throw new Error(value + " has no associated option");
option = $(option);
if(!!option.data("hidden") === !onoff){
return
}
if(onoff){
var oldStyle = option.data("oldStyle")
option.data("oldStyle", "");
option.attr("style", oldStyle);
option.data("hidden", !onoff);
return;
}else{
var oldStyle = option.attr("style");
option.data("oldStyle", oldStyle);
option.attr("style", "display:none");
option.data("hidden", !onoff);
return;
}
})
}