Variable Parameters - sc_field_display()

Is there anyway to feed a variable into sc_field_display as the field parameter? I have about 20 fields on a control that in different cases need flipped off. I would really like to use a loop for this, otherwise I’m going to have an ugly and long if or switch statement controlling these 20 fields.

Thanks

I figured out a work around.

The sc_field_display(); only hides this fields through style=“display: none;”

If anyone else is trying to do this you just need to crate a javascript method called hideFields in your application and allow a parameter called fields. After that is created paste the code below in your new method.

var fieldsAR = fields.split(",");
var arrayLength = fieldsAR.length;
for (var i = 0; i < arrayLength; i++) {
document.getElementById("hidden_field_label_"+fieldsAR[i]).style.display = 'none';
document.getElementById("hidden_field_data_"+fieldsAR[i]).style.display = 'none';
}

Then whenever you need to call this method from another script use the below code with your fields in the fields string.

​$fields = "field1,
field2,
field3";

$js_para = array($fields);
sc_ajax_javascript("hideFields", $js_para);

WOW, this is just what I was looking for, thanks for sharing it bro :slight_smile: