Reputation: 11
I'm changing the form action with:
window.onload = function() {
document.getElementById('pdf').onclick = addExportEvent;
document.getElementById('xls').onclick = addExportEvent;
document.getElementById('xml').onclick = addExportEvent;
document.getElementById('csv').onclick = addExportEvent;
}
function addExportEvent() {
data = grid.getAllGridData();
document.getElementById('dados').setAttribute('value', encodeURIComponent(JSON.stringify(data)));
formulario = document.getElementById('formulario'); // Line 55!
formulario.action = 'php/' + this.id + '.php';
formulario.submit();
return false;
}
But it doesn't work with Internet Explorer. It returns the following error:
Message: The object doesn't support the property or method.
Line: 55
Character: 2
Code: 0
URI: http://www.site.com/javascript/scripts.js
Upvotes: 1
Views: 875
Reputation: 11068
I think Andy E's head's comment hit it on the, well, head. You are assigning the correct element, but not declaring it using var which makes IE gag and choke and all kinds of bad stuff. Other browsers handle this just fine. So you are trying to access formulario instead of declaring it, which means it never gets the value of id: formulario
function addExportEvent() {
var data = grid.getAllGridData();
document.getElementById('dados').setAttribute('value', encodeURIComponent(JSON.stringify(data)));
var formulario = document.getElementById('formulario'); // Line 55!
formulario.action = 'php/' + this.id + '.php';
formulario.submit();
return false;
}
Upvotes: 1