cancel
Showing results for 
Search instead for 
Did you mean: 

Interactive forms (Offline) scripting logic

Former Member
0 Kudos

Hi All,

I have build a simple interactive form (offline) that displays multiple lines from a internal table with a check box against each record and an email submit button.

I would like to validate if the user selects at least one check box in the table (Let's say table name is "ITAB" and check box field is "SELECT") before the actual submission. I believe we should implement some scripting logic for the even "preSubmit".

Appreciate if some one could share the scripting logic to handle this validation at the client side.

Waiting for your response.

Thanks in advance.

Regards,

Hemanth

Accepted Solutions (0)

Answers (2)

Answers (2)

OttoGold
Active Contributor
0 Kudos

If you´re not sure about the event, create a "normal" button and use its click event. This way you can test if your script works and the problem is the event.

Maybe you should start reading first: http://www.adobe.com/devnet/livecycle/articles/lc_designer_scripting_basics/lc_designer_scripting_ba...

Otto

OttoGold
Active Contributor
0 Kudos

Hello,

in this thread you find how to loop at all the form elements:

for each element you check the value, if is "checked" you set some variable (define as: var result = "";) to result = "X".

At the end check the result value like if (result != "X") app.ale-rt("No rows has been selected, please select at least one").

Regards, Otto

p.s.: you write ale-rt as one word, but i cannot write it in here, it interferes with this forum underlying program logic/syntax.

Former Member
0 Kudos

Hi,

Thank you very much for your response. Sorry for the delay from my end.

I tired the below logic based on your suggestion. I implemented the logic in the preSubmit event of the "Email Submit Button". It did not seem to work and I think I am missing somewhere.


var norows = xfa.resolveNodes("data.ITAB.DATA[*]").length;
var result = "";
for ( var i=1; i<=norows; i++)
{
result = xfa.resolveNode("xfa.dataset.data.ITAB.tableData<i>.select").value
}
if (result != "X")
app.ale rt("No rows has been selected, please select at least one")

<-- Ignore the space in "alert", that is just to avoid the post error-->

Appreciate your help in this regard.

Thanks,

Hemanth

OttoGold
Active Contributor
0 Kudos

Of course:))

it should be like:

for (...) {

var temp = xfa.resolveNode("xfa.dataset.data.ITAB.tableData<i>.select").value;

if (temp == "if_is_checked") { result = "X"; break; }

}

because your code is doing this: "if the last row is not selected (because your code overwrites the result value for every row), then app.alert"...

please check the right variable value to test, instead of my "if_is_checked" and I am not sure if break exists in JS, but this is only for the performance purposes.

Otto

Former Member
0 Kudos

Oops...I missed that.

However even if result value is over written with the last record, and if I am not selecting the check box in the last record it should prompt the error message right? But that's not the case here :(.

I have changed the logic as per the suggestions (using a temporary variable) and that did not work too. I am very new to java script and scripting in adobe forms (in fact this is my first one) so that not quite sure if I am missing anything else.

Do you think something is going wrong with the event I have selected?

I have read somewhere that 'preSubmit' of submit/email submit button is similar to 'click' event of normal button. Hence used my logic there.

Any thoughts?

Have a nice day.

Regards,

Hemanth

Former Member
0 Kudos

Hi Hemanth,

An alternative could be to make the submitt button read-only/active if the condition is true. You could do the check every time one of the check boxes changes its state.

Another approach is to use an invisible submit button and a standard button. If everything is fine (checked for the click event of the standard button) you could call execEvent("click") on the invisible button.

Regards,

Juergen

Former Member
0 Kudos

Hi,

Thanks for the alternate approach. I am busy with other ciritical stuff and will look into this same later.

I believe I need to go through the link that you have sent; before I start working on the scripting.

Thanks again

Regards,

Hemanth