I am having trouble with query strings. In my menu I have a simple anchor tag <a href="learn_more.aspx?isOn=2&isAt=2"><div class="learn_more" id="ab2"></div></a> PHP: When I click on this link, the code should switch the class but it is not getting into my else if (qsParm['isOn']==2 && qsParm['isAt']==2) statement. I don't know why it's not working. Any help greatly appreciated. <!--this java script code checks the isOn state and switches the class to an selected sate--> <script type="text/javascript"> var qsParm = new Array(); function qs() { var query = window.location.search.substring(1); var parms = query.split('&'); for (var i=0; i<parms.length; i++) { var pos = parms[i].indexOf('='); if (pos > 0) { var key = parms[i].substring(0,pos); var val = parms[i].substring(pos+1); qsParm[key] = val; } } } qsParm['isOn'] = null; qsParm['isAt'] = null; qs(); if (qsParm['isOn']==2){ document.getElementById('ab2').className="learn_more_selected"; }else if (qsParm['isOn']==2 && qsParm['isAt']==2){ document.write('You selected ' + qsParm['isOn'] + qsParm['isAt']) document.getElementById('ab2').className="learn_more_selected"; document.getElementById('Lm1').className="what_hemorrhoid_selected"; }else if (qsParm['isOn']==2 && qsParm['isAt']==3){ document.getElementById('ab2').className="learn_more_selected"; document.getElementById('Lm2').className="treatment_procedure_selected"; }else if (qsParm['isOn']==3){ document.getElementById('ab3').className="about_us_selected"; } else if (qsParm['isOn']==4){ document.getElementById('ab4').className="gutman_selected"; } else if (qsParm['isOn']==5){ document.getElementById('ab5').className="contact_selected"; }else { document.getElementById('ab2').className="learn_more"; document.getElementById('ab3').className="about_us"; document.getElementById('ab4').className="gutman"; document.getElementById('ab5').className="contact"; document.getElementById('Lm1').className="what_hemorrhoid"; document.getElementById('Lm2').className="treatment_procedure"; } </script> PHP:
I think I found my own solution. I am not exactly sure why but my isAt value needed to be a number instead of a string. ie, isAt=Lm1 (no go) but isAt=2, OK. Go figure!