Skip to content
Advertisement

If I click on Tab, it doesn’t response. Why?

Problem is I cannot click the Tabs on the website and If i click on Tabs; it show

Uncaught Type Error: Cannot set properties of null (setting ‘value’).

Is there any way to fix this? Also, I am a beginner and I don’t know how to fix this. Codes are written in PHP and Javascript.

JavaScript

Above codes are index.php codes.

JavaScript

Above codes are Javascript codes. Error says in Javascript and How to fix that?

Advertisement

Answer

The error occurs in the JS code and is due to the HTML generated in PHP which is missing an id attribute.

You seem to get the error here: document.getElementById(tabid).value = tabname; because document.getElementById(tabid) is null.

When it looks for the element with id str_tab it doesn’t find it. The only element in the HTML which could be the desired one has the attribute name="str_tab" and it’s your hidden field. You have to add the missing id="str_tab" attribute to this hidden field.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement