Expand my Community achievements bar.

SOLVED

Problem with working with add/remove instance incorporating checkbox

Avatar

Level 1

I have come into a problem I have been trying to figure out for the past week. I had googled for some guidance yet I found nothing useful.

Currently, I have a table which has an addinstance button and removeinstance button. The script for these work.

What I am looking to do is the row starts off being in readOnly format and when I select a checkbox, one of the cell will become open ( I have a table with 12 cell in a row and about 6-7 checkboxes which will open certain cells). However, when I add an instance and one of the checkboxes is checked…the next row is still readOnly. How do I target those certain cells? if I have a checkbox checked and I add a new row..those certain fields will be open for all the cell in that column.

If anyone could assist me, that would be great.

1 Accepted Solution

Avatar

Correct answer by
Level 10

Glad it worked! I wasn't too sure I could get it to work myself, took a few tries getting things in the correct order.

There quite a few threads covering that here, I haven't tried playing with it myself.

This one has a sample by Paul which has a bunch of different email options:

http://forums.adobe.com/message/2109201#2109201

And this one looks like it's got a bunch of info:

http://forums.adobe.com/message/1356572#1356572

View solution in original post

5 Replies

Avatar

Level 10

I think there's a couple of ways to go about this.

One would be to loop through the row instances setting access where appropriate.

The other may be a little easier:

On the fields in question put a script on the Initialize event that looks at the state of the button that controls their access. That way when the field is initialized it knows whether it is supposed to be open or not.

if (button==1){

this.access="open";

}

else{

this.access="readOnly";

}

It may get weird if you need to check if the state of the button changes. Then you may have to use the looping method, or perhaps forcing a relayout (xfa.layout.relayout()) would work to reset access.

Avatar

Level 1

Hello Jono,

Thank you for your assistance, I tried to complete what you had explain. I am a novice and not sure how to complete the first and last option and the second option, I manipulated the code but was unable to get any results. I have attached my form, do you think you could walk me through this?

I have the checkboxes access and readOnly the certain cell fields in the table and an addinstance/removeinstance button. Those new rows, i want to reflect the original row.

I understand your approach to instead have the checkboxes perform the task but the cells.

Your help would be much appreciated.

Thanks,
Randy

Avatar

Level 10

This should get you going I think.

I just worked with the "Additional Lines" checkbox and the "Add" checkbox in the table, you'll need to copy and adjust the scripts for the other objects.

Script is on the Change event for "Additional Lines". This script will loop through the rows and toggle access on all of the matching fields, in this case the "addcb" field.  Don't know if that's what you need or not, but I did it in case someone has already added some rows and then decides to click the "Additional Lines" checkbox:

if (this.rawValue == 1)
{
    var vFields = xfa.resolveNodes("form1.Subform4.Table1.Row1[*].addcb");    
    for (var i=0; i <= vFields.length-1; i++)
    {       
        vFields.item(i).access = "open";
    }
}
else
{
    var vFields = xfa.resolveNodes("form1.Subform4.Table1.Row1[*].addcb");
    for (var i=0; i <= vFields.length-1; i++)
    {       
        vFields.item(i).access = "readOnly";
    }
}

Script on the Initialize event of the "addcb" field. This script checks the "Additional Lines" checkbox to see what access the field should have when it is created:

if (Subform1.additionallines.rawValue == 1)
{
    this.access = "open";
}
else
{
    this.access = "readOnly";
}

Hope that helps!

Avatar

Level 1

Thank you so much, Jono! it works perfectly, i just added a extra line of script to do exactly what i needed. I dont think i would have been able to do that without your help.

With that , i have 1 last request if you could possibly help...I was wondering, there is a email submit button in the custom section...is there a way to have the subject display a standard text along with whatever a person enters into a certain text field?

example: Change Request Order # --> (Standard across the board) [Text Field] --> (number manually entered into the textfield)

Avatar

Correct answer by
Level 10

Glad it worked! I wasn't too sure I could get it to work myself, took a few tries getting things in the correct order.

There quite a few threads covering that here, I haven't tried playing with it myself.

This one has a sample by Paul which has a bunch of different email options:

http://forums.adobe.com/message/2109201#2109201

And this one looks like it's got a bunch of info:

http://forums.adobe.com/message/1356572#1356572