<script type="text/javascript"> <!-- var areaname = "<?php echo $arename; ?>"; if(areaname = "listings-residential"){ document.location.href="residential.php"; } else { document.location.href="commercial.php"; } //--> </script> Code (markup): This is the code I am using and regardless of what info is in the variable it always re-directs to the first link.
<script type="text/javascript"> <!-- var areaname = "<?php echo $arename; ?>"; if(areaname [COLOR="red"]==[/COLOR] "listings-residential"){ document.location.href="residential.php"; } else { document.location.href="commercial.php"; } //--> </script> Code (markup): You need 2 equals signs otherwise your just setting areaname to the value on the right. = is set variable one to variable 2 == is the comparision operator Check out w3schools.com for some great tutorials.
I adjusted it and now it always go to the "else" link in the code. Hmmmmmmmm. I will have to check out those tutorials.