cancel
Showing results for 
Search instead for 
Did you mean: 

Hiding fields based on condition

0 Kudos

Hi,

I need to hide a certian field in the form based on value in another field, I used Javascript for this and the code is below. The form will have multiple pages and the field thats need to be hidden is hidden only in the first page and not others. Please suggest what needs to be done to correct this. I am also not sure in which event i have to use this code. Now I am using it in Initialize event.

var lines = data.Subform1.DATA.LINES;
for (var curpage=1;curpage<=lines;curpage++)
{ 
if (this.rawValue = 'AD') {data.Subform1.DATA.REFNUM.presence = "hidden";}
if (this.rawValue = 'FR') {data.Subform1.DATA.ZREBZG.presence = "hidden";}
if (this.rawValue = 'SS') {data.Subform1.DATA.ZREBZG.presence = "hidden";}
}

Accepted Solutions (0)

Answers (11)

Answers (11)

0 Kudos

Rakesh,

Issue could not be solved, going with both fields on form for now.

0 Kudos

Hello Rakhi,

Id: 346-085-050

Login: go.mikogo.com

rakesh_m2
Contributor
0 Kudos

Hello Kiran,

Change the event from calculate to layout: ready or form: ready and try once

Thanks

Rakesh

0 Kudos

Rakhi,

Id for Mikogo, 751-167-424

rakesh_m2
Contributor
0 Kudos

sorry kiran,

I was in meeting. just came now.

could you please start a new session and give me new id.

0 Kudos

Rakhi, I don't have mikogo. I will install it and send u id soon.

0 Kudos

No, Still doesn't work...Is there any other way to hide the fields?

rakesh_m2
Contributor
0 Kudos

Do you have mikogo on your system.

If so please provide me the id: so that I can check

Rakesh

0 Kudos

This code has to be placed in the calculate event for the page right?

0 Kudos

No, It did not solve my problem. I see both fields ZREBZG and REFNUM overlapped on all pages.

0 Kudos

Hello Rakhii,

AD, FR, SS are values of a different field. I overlapped ZREBZG and REFNUM. The field which containds AD, FR, SS are at a different place on the form. I hope your code works in that case.

rakesh_m2
Contributor
0 Kudos

this code do not matter with the place of the field in the form, it will work in all cases. If your question is solved, Please mark the question as answered.

Pleaase let me know, if you see any issues.

Thanks,

Rakesh.

rakesh_m2
Contributor
0 Kudos

instead of this.presence try using fields.item(i).presence

Hope this should solve your problem,

rakesh_m2
Contributor
0 Kudos

Hello Kiran,

The code which you wrote will acess every time the field in first page. Please try this code in calculate event and let me know if you see any issues. This will compute values for each page dynamically

var fields = xfa.layout.pageContent(xfa.layout.page(this)-1, "field", 0);

for (var i=0; i <= fields.length-1; i++)

{

if (fields.item(i).name == "REFNUM")

{

if(fields.item(i).rawValue == 'AD')

this.presence = "invisible";

}

if (fields.item(i).name == "ZREBZG")

{

if(fields.item(i).rawValue == 'FR')

this.presence = "invisible";

}

if (fields.item(i).name == "ZREBZG")

{

if(fields.item(i).rawValue == 'SS')

this.presence = "invisible";

}

}

Make sure that the field names which you are going to make invisible are not used anywhere in the form.

Please let me know, if you see any issues.

Thanks,

Rakesh

Edited by: rakhi966 on Aug 25, 2011 6:44 PM

0 Kudos

Hello Hendrix,

I am using this script in the initialize event for the field which controls the appearance of ZREBZG and REFNUM. What ever I do only the fields on the first page are being hidden. Are you suggesting to code events for the fields ZREBZG and REFNUM instead of the field which controls the appearance of these fields?

nol_hendrikx
Active Contributor
0 Kudos

Dear Kiran,

In the initialize event the data might not available yet.

You can use the events for the REFNUM and ZREBZG field and make a condition just the other way around.

Hope this helps.

Cheers,

Noel