I have 2 buttons which are change status of variable, If status is 1 it shows div, if not it hides dive. I need to catch this variables changes and add condition inside different script, which will work without page refresh and will add or hide script depends on variable. Here is example code:
var point_access = 0;
document.getElementById('button 1').onclick = function() {
if (point_access == 0) {
point_access = 1;
//do smth else
}
}
document.getElementById('button 2').onclick = function() {
if (point_access == 1) {
point_access = 0;
//do smth else
}
}
Here is the code that I want to show or hide script, which is depends on variable point_access
map = new ol.Map({
layers: [
new ol.layer.Tile({
//smth here
}),
new ol.layer.Tile({
//smth here
}),
vectorLayer //this is the variable inside script which i want to show or hide
//if(point_access == 1){
// vectorLayer
//}
],
//smth else
});
So, how can I do it work live? It all time get point_access
value as 0
and do not listen to my value change on click.