Hello,
There is a way to retreive by js, on the onchange event of a FileUpload Widget, the name of the first file selected ?
Thank you
FileUpload widget : how to retreive the 1rst file name
-
- Profound User
- Posts: 62
- Joined: Sat Feb 18, 2012 12:03 pm
- First Name: Patrick
- Last Name: THOMAS
- Company Name: Oo2
- Country: France
- Contact:
- matt.denninghoff
- Profound Logic Staff Member
- Posts: 115
- Joined: Wed Feb 10, 2016 3:53 pm
- First Name: Matthew
- Last Name: Denninghoff
- Company Name: Profound Logic Software
- State / Province: Ohio
- Country: United States
- Contact:
Re: FileUpload widget : how to retreive the 1rst file name
Yes, it is possible. If you inspect what the FileUpload widget does to the DOM tree after you click "Select Files", you can see that a hidden <input> tag was added for each file you chose.
It looks like the FileUpload's onchange doesn't behave the same as with the simpler widgets; you can't reference "this.value". The onchange handler passes an argument to your code, but our obfuscator changes the name of the function argument. So for your code to work consistently between different versions of Profound, you'll need to use the special "arguments" array that is passed with every JavaScript function.
This code should get you started:
It simply outputs the values of each <input> tag to the console. There is always one extra input tag with no value--it gets a value after you select another file, and another input tag is created.
Also, it looks like the FileUpload widget only fires the onchange event after you click "Select Files"--clear and remove do not fire the event.
It looks like the FileUpload's onchange doesn't behave the same as with the simpler widgets; you can't reference "this.value". The onchange handler passes an argument to your code, but our obfuscator changes the name of the function argument. So for your code to work consistently between different versions of Profound, you'll need to use the special "arguments" array that is passed with every JavaScript function.
This code should get you started:
Code: Select all
var inputs=arguments[0].target.parentNode.parentNode.getElementsByTagName("input");
for(var i=0; i < inputs.length; i++){
console.log("i",i," value",inputs[i].value);
}
Also, it looks like the FileUpload widget only fires the onchange event after you click "Select Files"--clear and remove do not fire the event.
-
- Profound User
- Posts: 62
- Joined: Sat Feb 18, 2012 12:03 pm
- First Name: Patrick
- Last Name: THOMAS
- Company Name: Oo2
- Country: France
- Contact:
Re: FileUpload widget : how to retreive the 1rst file name
Matt,
Thank you, good tricks
Thank you, good tricks
Who is online
Users browsing this forum: No registered users and 1 guest