The customer has a need to embed a piece of our own in an InfoPath form, and to update an InfoPath field after the calculation.
1. How to get to that field
Because the HTML produced by InfoPath is very complex, nested too much, followed by a messy ID, and when editing and viewing the ID is different, but each field in the HTML has a property called ' Originalid ', this ID is relatively fixed. So you can use this property to get the appropriate control.
For example: $ ("input[originalid= ' V1_i1_t9 ')")//This gets the input
2. How to assign a value to it, and when saving the form, the value of the successful deposit in.
In InfoPath, if you simply assign a value to a input in jquery and then save it, the value is not saved. We have to simulate something like someone going to actually fill out that value and then save it. Explanation after the reason.
$ ("input[originalid= ' v1_i1_t10 ')"). Val (Totalprice); Assign a value of $ ("input[originalid= ' v1_i1_t10 ')". focus (); Similar to the mouse focus placed in the text box is $ ("input[originalid= ' v1_i1_t10 ')"). blur (); Mouse Focus Left//This is a complete filling of the worthwhile process.
The reason is that in InfoPath, the real field value exists in a configuration file, and the value of the current HTML input or other control is changed, and when the mouse is moved, it triggers a process to write the value to the configuration file, so if you assign a value to jquery, Need to simulate a bit.
[InfoPath] uses jquery to assign a value to an Infopath form's field. How to set value to Infopath field by Jquery