Expand my Community achievements bar.

how to set presence of a cell in a row of a table (scripting)

Avatar

Former Community Member
Hello,



i have been struggling with this code. Please help



----- form1.Table21.Row2.Cell3::change: - (JavaScript, client)



if (this.boundItem(xfa.event.change) == 2) {

Row3.cell3.setAttribute("visible", "presence");

} else {

Row3.cell3.setAttribute("invisible", "presence");

}



I have been trying to set the presence of cell3 of Row3 in the table, on the change in value of the same column cell (Cell3) in its previous row Row2.



This script is written on "Change" event.



What am i doing wrong?



Please help
5 Replies

Avatar

Level 5
I tried to understand the situation but quite off my knowledge... but here is the sample code for setting the presence property of any object.



Row3.cell3.presence = "visible" //to make it visible

Row3.cell3.presence = "invisible" //to make it invisible

Row3.cell3.presence = "hide" //to make it hide



Try in your context and let us know the results.



Good luck,

SekharN

Avatar

Former Community Member
Hi Sekhar,



Thanks for yor reply.



i tried the following code, which seems to work, but with an error :(



if ( Row2.Cell3.rawValue == "Yes" )

Row3.Cell3.setAttribute("visible", "presence")

else if ( Row2.Cell3.rawValue == "No" ) {

Row3.Cell3.setAttribute("invisible", "presence")

else if ( Row2.Cell3.rawValue == "Not Applicable" ) {

Row3.Cell3.setAttribute("invisible", "presence")



i have to select the value twice in the dropdown list. when i select the same value twice, the effect takes place...



Any idea... why is it behaving so?



is it that the value is acknowledged the second time only?

but then why not first time....?



Any clue how could i resolve this problem...



Thanks in advance

Mona

Avatar

Level 5
rawValue assigned only after the selection completes. That means it gets assigned only after you select and exit the field.

Here is what happening:

1. Let us say the rawVlaue = null when form is displayed.

2. User makes a selection but if you have code running at 'change' event and you use rawValue to determine the selected value it still returns 'null' but not selected item.

3. After you ran the code when you move out of the field to other rawValue gets assigned with the selected item.

4. When you return to the same field for the second time to select its rawValue is already set to the selection made in the previous action. And your code works based on the value selected in previous action irrespective of your new selection. Though it appears it works for second time it is really not.



so you have two choice here to get the situation straight

a) Move your code to 'exit' event where rawValue gets assigned with the selections made in that action.

b) or change your comparison criteria based on current selection. In this case (xfa.event.change) may return you current selected value if you still would like your code to run at 'change' event. You may also use this.boudItem(xfa.event.change) to determine new selected value. Search for those two context in this forum you may get additional help.



Hope this helps,

SekharN

Avatar

Former Community Member
Hi Sekhar,



Thanks for your inputs. I solved the problem.

Following is the code which is used at the CHANGE event of the field( Drop down list) to make this work :)



if (this.boundItem(xfa.event.change)=='Yes'){

Row3.Cell3.presence = "invisible";

}else if (this.boundItem(xfa.event.change)=='No'){

Row3.Cell3.presence = "visible";

}else if (this.boundItem(xfa.event.change)=='NA') {

Row3.Cell3.presence = "invisible";

else if (this.boundItem(xfa.event.change)==null){

Row3.Cell3.presence = "invisible"; }



Regards

Mona

Avatar

Former Community Member
hi i need help to invisible the column in a table when the user click the button.

And this column should invisible when i send the form with this table through mail.