Adding a browse button (html input file control) to a CRM form
Here's a quick example of how to put a browse button (html input file control) on a CRM form and then populate another field when it changed. Put this into your onload and update the field name 'new_filepath' in the inputF_onChange method to the name of the field that you would to be populated with the full path.
inputF = document.createElement('input');
inputF.type = 'file';
inputF.onchange = inputF_onChange;
tbl = crmForm.all.tab0.getElementsByTagName('table');
if (tbl && tbl[0]) tbl[0].parentNode.insertBefore(inputF, tbl[0]);
function inputF_onChange() {
if (inputF && inputF.value)
crmForm.all.new_filepath.DataValue = inputF.value;
}Here's a list the members exposed by the input type=file object.
http://msdn.microsoft.com/en-us/library/ms535263(VS.85).aspx
It should be noted that the above example will not work for IE8 as JavaScript can no longer read the full path from the value property.
As an alternative I would recommend trying a more supported method, for example, create an ISV page with the input file control and read the path server side and use javascript to populate the control on the parent CRM form.
Labels: CRM4, JavaScript

0 Comments:
Post a Comment
Links to this post:
Create a Link
<< Home