Using custom.js to set the value of a text field
Is it possible to set the value of a text field and have frevvo include this value in the final submit.
My problem is that the file name for a given upload is not linked to the attachment-tag id. I am able to get the file name and attachment id using (fileNameTextField is a text input field):
var uploads = document.getElementsByClassName('f-file-upload-file-name');
var uploadFileNames = "";
for(var i=0;i<uploads.length;i++){
if(i>0){
uploadFileNames = uploadFileNames + "#";
}
uploadFileNames = uploadFileNames + "ID:" +uploads[i].id + "|TITLE:" + uploads[i].title;
}
var fileNameTextField = document.getElementsByName('fileNameTextField')[0];
fileNameTextField.value = uploadFileNames;
The text field gets updated with the values as expected, however, frevvo does not see the text field as updated and thus the final submit does not include the value set by the custom.js method.
I was thinking that maybe some sort of event can be fired to pretend that a user has typed the value in the text field but I am unable to make it work.
-
You will need to add this line at the end of your script to update the text field value:
UberController.valueChangeObserver({target:fileNameTextField}, document.getElementById('_x_gGlVpqEeKwG6IPeCabGQ'));
Note that you will need to replace _x_gGlVpqEeKwG6IPeCabGQ in above line with the DOM id of your fileNameTextField control (a frevvo control is usually a DIV HTML element, so you will need id of a <div> element, NOT of <input> element)
0
Please sign in to leave a comment.
Comments
1 comment