How to make a javascript function execute in the order I write it



I have a function in the click event of a button: ();

xfa.form.remerge ();

textfield1.access = "open"

Row1 and row2 works but row3 does not because I understand java is working in an asynchronous state.

All rows run at the same time but remerge takes more time and it ends last. So in the very end, it makes textfield1 to its default state, read only.

How can I make these three rows execute in the order I write them? How can I make row3 waits to run until row2 ends?

Accepted Solutions (0)

Answers (6)

Answers (6)



What if you left textfield1 as open. You could lock the field on an exit event.

1- user enters data in field1

2- on exit the field is set to read only

3- next user clicks the button to reset the form

4- form is reset to its original presence.

5- textfield1 is open

The issue is that remerge seems to be a final event. Nothing executes after that.



textfield1 is read only by default. By pressing the button, user should reset the whole form and only then would enter data in textfield1. On the other hand after pressing the button, form data and structure resets but textfield1 remains read only. Row3 can not create any change. textfield1 should become open but it remains read only. I think its because of the asynchronous nature of java code. Row3 do its job in the first place. But all three lines run at the same time and because of this, Row2 kills Row3's action.

My purpose is to avoid people to share already filled forms between each other and then submit them as they personally filled it. textfield1 is for a unique tax id number and a person at least must change this field to fill the form properly.

So if the code works, a person can not enter his tax id number to textfield1 just after opening the form because it is read only. The only way to proceed would be pressing the button, by doing this he resets all the data and form structure + make textfield1 open so he can enter data to it. After entering tax id number, I have a seperate code that makes textfield1 read only again. So whenever you want to change the tax id number, you must reset all the form and structure.

I was thinking that this is a good work flow but it does not work.

Is there a way first "xfa.form.remerge ();"  and AFTER THEN "textfield1.access = "open"?

On the other hand, if I can remerge a form partially, it would also work.



what does not work for row 3? when you remerge you essentially are resetting the form back to its original state. What state does row 3 start out in? what happens to it after remerge




Its because of the effects of the remerge method. Its forces the PDF viewer to create a new form DOM from the template and data DOMs. During this process all pending scripts will be terminated.