I have < a href = "index.php?state=0">state</ a > On each click I want to toggle the state value Suppose it's now index.php?state=0 next click it will be index.pho?state=1 and so on. How can I achieve this using php or vanilla javascript
Offbit, but you can try something like this
<a href = "index.php?state=0" id="mya">state</a>
var st = 1
document.getElementById("mya").addEventListener('click', function(){
var lnk = document.getElementById("mya");
window.open(
lnk.href,
'_blank'
);
lnk.innerHTML = "State";
lnk.setAttribute('href', "index.php?state="+st);
st++;
return false;
});