Reputation: 173
I have the following json file.
{
"home_page_boolean":true,
"syllabus_page_boolean":true,
"schedule_page_boolean":true,
"hws_page_boolean":true,
"project_page_boolean":true,
"banner_school_image_file":"",
"left_footer_image_file":"",
"right_footer_image_file":""
}
I'm trying to check wether one of the booleans is true or false. Notice that the way I have it now is that the value for the booleans is a boolean value and not a string value, (its not "project_page_boolean":"true")
This is what I tried,
if(data.homePageBoolean === true){
navbar+= "<a id='home_link' class='open_nav' href='index.html'>Home</a>";
}
and
if(data.homePageBoolean.toString() === "true"){
navbar+= "<a id='home_link' class='open_nav' href='index.html'>Home</a>";
}
but It doesn't work. I'm pretty sure the solution is simple but I can't figure it out
Upvotes: 0
Views: 77
Reputation: 47
I think it should be as follows :
if(data.home_page_boolean === true){
navbar+= "<a id='home_link' class='open_nav' href='index.html'>Home</a>";
}
Upvotes: 0
Reputation: 150
Try this
if(data['home_page_boolean']){
navbar+= "<a id='home_link' class='open_nav' href='index.html'>Home</a>";
}
Upvotes: 1