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

Avatar

Avatar

evreny69628048

Avatar

evreny69628048

evreny69628048

01-11-2017

I have a function in the click event of a button:

xfa.host.resetData ();

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)

Avatar

Avatar

mouslander

Avatar

mouslander

mouslander

06-11-2017

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.

Avatar

Avatar

evreny69628048

Avatar

evreny69628048

evreny69628048

04-11-2017

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.

Avatar

Avatar

mouslander

Avatar

mouslander

mouslander

03-11-2017

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

Avatar

Avatar

radzmar

MVP

Total Posts

2.6K

Likes

386

Correct Answer

485

Avatar

radzmar

MVP

Total Posts

2.6K

Likes

386

Correct Answer

485
radzmar
MVP

02-11-2017

Not that I'm aware of. You have to find another solution to control the access property ot the textfield.

Avatar

Avatar

evreny69628048

Avatar

evreny69628048

evreny69628048

02-11-2017

OK, is there a way to run remerge for only a limited section of the form? For example remerge all form but TextField1.

Avatar

Avatar

radzmar

MVP

Total Posts

2.6K

Likes

386

Correct Answer

485

Avatar

radzmar

MVP

Total Posts

2.6K

Likes

386

Correct Answer

485
radzmar
MVP

01-11-2017

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.