Once the drawing datatable is filled, I want to use the "Drawing Present" textbox to keep track of how many drawings are filled among the 6 drawings. How do I achieve it?
I would like the Drawings Present to store something like "Drawing #1 Drawing #2 ...". If a specific drawing number is deleted, I want the Drawing Present textbox to delete that as well.
And how do I automatically select the check box when a datatable is filled. So users don't have to manually select the checkbox. Thanks.
You can call the function when a user change the data table. The function checks if the table contains entries and populates other fields. This is the code example for one DataTable control:
fd.control('Drawing1').$on('change',function(value) {
var checkBox = fd.field('Drawings').value;
//add the option if the table has enteries
if(value.length > 0 && !checkBox.includes('Drawing 1')){
checkBox.push('Drawing 1')
}
//remove the option if the table has no enteries
if(value.length < 1 && checkBox.includes('Drawing 1')) {
var index = checkBox.indexOf('Drawing 1');
if (index > -1) {
checkBox.splice(index, 1);
}
}
//populate fields
fd.field('Drawings').value = checkBox;
fd.field('Drawings').selectedOptions = checkBox;
fd.field('DrawingsPresent').value = checkBox.join('; ');
});
Make sure you are using valid fields' and controls' names in the code.
I am just wondering How can i make my code more effective if I don't want to include the checkboxes, just textfield to store which drawing tables are present?
And I realize that using the checkboxes, after the form is saved and reopened, all the selections on the checkboxes are gone.