Hiding merge fields in my survey that are blank

0

Background: I often need to pipe options into dropdowns that are part of a contact form or custom group. (You can pipe easily into a stand-alone dropdown, but not into a dropdown that is part of contact form or custom group).

To get around this, I just use merge codes. For example, if Question 1 has 10 “check box other required” fields, then when I set up the dropdown, I give the dropdown 10 fields and each one is a merge code from each option in question 1. Without script, each merge field that doesn’t have an answer in question 1 will show as a blank answer in the dropdown.

Years ago a SG person wrote me some script to hide/disable all the empty fields in a dropdown and it’s been working great; I can get the survey to do what I need.

Now, however, I need to do the same thing with a textbox list inside a contact down and the same script isn’t working. In theory (at least in my non-script mind), it seems it should be a simple matter of change a few things to make it work with text boxes too, but I obviously don’t know what I’m talking about. 

Question: Is there a way to modify the script below to hide blank merge fields in checkbox lists? Or does someone know a better option for hiding the lines with blank merge codes? Ideally, SG would just let you pipe into sub-questions, but until then, this is the best I could find. Many thanks!

 

//Made by Patrick
//Mild-Mannered Support Hero
//SurveyGizmo

//Specify to disable or remove the blank dropdown options here
var hideOrRemove = “remove”;

//Depending on specification, disable or remove
function options(param) {
$(‘.sg-type-multimenu select.sg-input-menu option, .sg-type-menu select.sg-input-menu option’).each(function() {
var label = $(this).attr(‘label’);
var value = $(this).val();
if (!label && value != “NoAnswer” && param == “disable”) {
$(this).attr(‘disabled’, true);
}

if (!label && value != “NoAnswer” && param == “remove”) {
$(this).remove();
}
});

$(‘.sg-type-table-menu-matrix select.sg-input-menu option’).each(function() {
var text = $(this).text();
var value = $(this).val();
if (!text && !value && param == “disable”) {
$(this).attr(‘disabled’, true);
}

if (!text && !value && param == “remove”) {
$(this).remove();
}
});

}

$(options(hideOrRemove));

Andy asked
    ×

    Login

    Question stats

    • Active
    • Views433 times
    • Answers0 answers
    • Followers1 follower