Reputation: 245
I am calling a function in JavaScript as shown
var count = 0;
function resetGroupsSelector(groupId){
//alert(groupId);
console.log("search_report_form:"+groupId)
//alert("search_report_form:"+groupId)
var id = "search_report_form:"+groupId;
document.getElementById("id").innerHTML("HI");
}
But I am getting
Uncaught TypeError: Cannot call method 'innerHTML' of null
error. I don't know what went wrong.
Upvotes: 2
Views: 99
Reputation: 5637
Simple syntax error:
document.getElementById("id").innerHTML("HI");
Should be changed to this:
document.getElementById(id).innerHTML = "HI";
^^ ^^^^^^^
Don't forget to remove the quotes from id
since it is a variable, so you want to make sure that you're passing the variable instead of the literal string "id"
Upvotes: 2