Error: Uncaught TypeError: Can not read property 'split' of undefined

0

I have the following problem, could anyone help me?

When I'm on a site that runs Javascript and I give a command.

The error happens in mySaved.js.196

Follow the line that I click on this site JavaScript claims the problem and does not perform what it would have to do:

function modifySaved(){
    var o_Element = document.getElementById(sourceElement.id);
    var applicationId = document.getElementById('applicationId').value;
    //pull report info string from the "reportInfoString" attribute
    var reportIdArrayStr = o_Element.reportInfoString;
    var reportIdArray = reportIdArrayStr.split('|'); //***NESTA LINHA O JAVASCRIPT DIZ QUE DÁ O PROBLEMA***
    var reportId = reportIdArray[0];
    var isShared = reportIdArray[1];
    var isScheduled = reportIdArray[2]; 
    var countryCode = reportIdArray[3];
    var divId = reportIdArray[4];

    modifySavedReport(reportId, isShared, isScheduled, countryCode, divId, applicationId);
}

I do not understand much, if you can identify something wrong there.

    
asked by anonymous 01.07.2015 / 20:32

1 answer

2

First you get an HTML element from the page:

var o_Element = document.getElementById(sourceElement.id);

Then you look for the "reportInfoString" in the found element. Since the Element type does not contain anything like this name, undefined is returned.

var reportIdArrayStr = o_Element.reportInfoString;

You try to use the method split in undefined and your JavaScript gives pau:

var reportIdArray = reportIdArrayStr.split('|');

If there is an attribute called "reportInfoString" in the HTML element found, then what you wanted was this:

var reportIdArrayStr = o_Element.getAttribute('reportInfoString');

Otherwise, maybe what you want is something else, but the fact is that your o_Element.reportInfoString does not do what you expect it should do.

    
02.07.2015 / 22:37