In a function in a calculated field, how do I check if a field has a CSS class?
-
I have a set of picture-buttons that hide and unhide fields by adding and removing a “hide” CSS class (mentioned here). I have a calculated field which looks at those fields as well as a dropdown and sets its value based on that. Here is the code for it:
(function(){ if(!$(fieldname324).hasClass(hide) && fieldname10 == 1) return 1; if(!$(fieldname324).hasClass(hide) && fieldname10 == 2) return 2; if(!$(fieldname325).hasClass(hide) && fieldname10 == 1) return 3; if(!$(fieldname325).hasClass(hide) && fieldname10 == 2) return 4; if(!$(fieldname326).hasClass(hide) && fieldname10 == 1) return 5; if(!$(fieldname326).hasClass(hide) && fieldname10 == 2) return 6; if(!$(fieldname332).hasClass(hide) && fieldname10 == 1) return 7; if(!$(fieldname332).hasClass(hide) && fieldname10 == 2) return 8; if(!$(fieldname333).hasClass(hide) && fieldname10 == 1) return 9; if(!$(fieldname333).hasClass(hide) && fieldname10 == 2) return 10; if(!$(fieldname334).hasClass(hide) && fieldname10 == 1) return 11; if(!$(fieldname334).hasClass(hide) && fieldname10 == 2) return 12; if(!$(fieldname335).hasClass(hide) && fieldname10 == 1) return 13; if(!$(fieldname335).hasClass(hide) && fieldname10 == 2) return 14; if(!$(fieldname336).hasClass(hide) && fieldname10 == 1) return 15; if(!$(fieldname336).hasClass(hide) && fieldname10 == 2) return 16; })();More specifically, I want to check which field is not hidden and the value of fieldname10. I’m not too familiar with javascript so I’m not even sure if the syntax is right, but from some basic testing
if(fieldname10 == 1) return 1;works as well asif(1==1 alert(true);, but when I try to find a field’s classlist using either javascript’sdocument.getElementByID("fieldname#").classList.containsor jQuery’s.hasClassneither work.How can I accomplish this?
The topic ‘In a function in a calculated field, how do I check if a field has a CSS class?’ is closed to new replies.