Expand my Community achievements bar.

SOLVED

How can I hide all blank fields on a page?

Avatar

Former Community Member

Hello

I want to hide all blank fields but to exclude tables as it messes up the table. It hides that blank cell with the borders and the table doesn't look right.

Currently my script below works it hides all the blank fields on that page.

Is it possible to get it to exclude on tables?

Thanks to all in advance.

function hideFields(myParentObject){

 

   var allChildElements;

var intNumElements;

var currentElement;

var j;

var temp;

 

//Get all the child nodes of the parent element

allChildElements = myParentObject.nodes;

 

//Total number of element in the object

intNumElements = allChildElements.length;

 

//Loop through all the child elements

for(j=0; j< intNumElements; j++){

currentElement = allChildElements.item(j);

//If the element is another subform we'll recusively call the function again

if(allChildElements.item(j).className === "subform"){

 

//if(currentElement.layout === "table"){ }

//else{

//}

else if(currentElement.className === "subformSet"){

 

//If the objects are fields, then we will want to hide them them

else if(currentElement.className === "field"){

//Check to see if the field is a button - do not count buttons

temp = currentElement.name;

 

if (temp.substring(0,6) !== "Button"){

if (currentElement.rawValue == "" || currentElement.rawValue == null){

currentElement.presence = "hidden";

 

//Check for exclusion groups - Radio Buttons

else if(currentElement.className === "exclGroup"){

// hide the exclusion group and not the individual radio buttons

if (currentElement.rawValue === ""){

currentElement.presence = "hidden";

 

} // end of for loop

} // end function

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

A table has a className of subform but will have a layout property with the value of "table".  If you find one of those then you wouldn't recurse into that subform.

But you code seems to have that commented out, was that not working for you?

Regards

Bruce

View solution in original post

3 Replies

Avatar

Former Community Member

I have seen the form Disable all fields, buttons, etc in Subform where they do the same thing.

But I want it to exclude tables.

I see that it treats Tables and subform's the same is there a way to distinguish between the two?

Avatar

Correct answer by
Level 10

Hi,

A table has a className of subform but will have a layout property with the value of "table".  If you find one of those then you wouldn't recurse into that subform.

But you code seems to have that commented out, was that not working for you?

Regards

Bruce

Avatar

Former Community Member

Hi

Thanks. That worked.

Just I didn't check the form properly with that change in, was expecting it to hide certain fields and it never did but forgot it was in a table and that's why it never hide them.