Alex Rivera | Logout

Javascript Error: Cannot Convert Object to Primitive Value

Asked 2011-07-12T15:59:58.607
15

I'm receiving this error using the following javascript code:

function tempTest(evt) {
    alert(evt.currentTarget.id);
    ct = document.getElementById(evt.currentTarget.id);
    rslt = document.getElementById('rslt');
    var props;
    for (var prop in ct) {
        if (ct.hasOwnProperty(prop)) {
            propVal = ct[prop];
            var propDat = prop + ' = ' + propVal;
            props += propDat + '<br/>';
        }
    }
    rslt.innerHTML = props;
}

This one has me puzzled. Any ideas?

Edit
Report

1 Answer

1

The problem lies with the propVal part of your code. Since that may not be converted into a string.

answered 2011-07-12T16:17:24.573

Your Answer