I have the following js that works correctly in IE, but not in firefox. It's just intended to hide a couple of form fields.
Using the Firefox error console, I see that the error generated is: "control is undefined" and it points to this line: control.parentNode.parentNode.style.display="none";
Adding if (control) before this line eliminates the error, but of course the fields don't get hidden either, so no dice. Any thoughts? Here's the full script:
Using the Firefox error console, I see that the error generated is: "control is undefined" and it points to this line: control.parentNode.parentNode.style.display="none";
Adding if (control) before this line eliminates the error, but of course the fields don't get hidden either, so no dice. Any thoughts? Here's the full script:
Code:
_spBodyOnLoadFunctionNames.push("hideFields");
function findacontrol(FieldName) {
var arr = document.getElementsByTagName("!");//get all comments
for (var i=0;i < arr.length; i++ )
{
// now match the field name
if (arr[i].innerHTML.indexOf(FieldName) > 0) {
return arr[i];
}
}
}
function hideFields() {
// uncomment the next line if you are troubleshooting
// debugger;
var control;
// Add the two lines below for each control to be hidden
control = findacontrol("State");
control.parentNode.parentNode.style.display="none";
control = findacontrol("PR Number");
control.parentNode.parentNode.style.display="none";
}