javascript - Uncaught TypeError -


can explain theses errors?

uncaught typeerror: cannot set property 'innerhtml' of null

uncaught typeerror: cannot read property 'style' of null

uncaught syntaxerror: unexpected token illegal

uncaught typeerror: object # has no method 'dispatchevent'

this test website

at point in page have:

function display_price(price, oid) {     ...      element = document.getelementbyid(oid);     if (valor != 'nan' && valor != null && valor != '')     {        element.innerhtml = valor + money_simbol; 

the last line causing error because element null. should add condition if(): is, change line:

if (valor != 'nan' && valor != null && valor != '') 

to this:

if (element && valor != 'nan' && valor != null && valor != '') 

in other words, it's practice always check return value of function before accessing properties.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -