id4382
Feb 4th 2008, 4:51 pm
Hello! I need help on how to create a var array for a list of about 500 cities. I am going to use this list in a geoIP variable to hide some text. I need the code to tell the if statement to look in the file 'cities.js', and if the city returned by the geoIP if statement equals a city in the list, then I need it to perform the function I have assigned.
Here is the code snippet, I need the list of cities to replace the 'stockton', without just typing them all out in the html file:
<script type="text/javascript" language="Javascript">
if (geoip_city() == "Stockton"){
HideText();
}
function HideText(){
var list = document.getElementsByTagName("font");
for (var i=0; i < list.length; i++) {
if (list[i].innerHTML.indexOf("Your Price:") > -1) {
list[i++].style.display="none";
if (list[i].innerHTML.indexOf("$") > -1) list[i].style.display="none";
}
}
}
//--></script>
Here is my array:
<script type="text/javascript">
<!--
var cityArray = NewArray();
cityArray[0] = "Alameda";
cityArray[1] = "Albany";
cityArray[2] = "Berkeley";
cityArray[3] = "Castro Valley";
cityArray[4] = "Dublin";
cityArray[5] = "Emeryville";
cityArray[6] = "Fremont";
cityArray[7] = "Hayward";
cityArray[8] = "Kensington";
cityArray[9] = "Livermore";
cityArray[10] = "Mount Eden";
cityArray[11] = "NAS Alameda";
cityArray[12] = "Newark";
cityArray[13] = "Oakland";
cityArray[14] = "Piedmont";
cityArray[15] = "Pleasanton";
-->
</script>
Anyone's help would be much appreciated!!!
Here is the code snippet, I need the list of cities to replace the 'stockton', without just typing them all out in the html file:
<script type="text/javascript" language="Javascript">
if (geoip_city() == "Stockton"){
HideText();
}
function HideText(){
var list = document.getElementsByTagName("font");
for (var i=0; i < list.length; i++) {
if (list[i].innerHTML.indexOf("Your Price:") > -1) {
list[i++].style.display="none";
if (list[i].innerHTML.indexOf("$") > -1) list[i].style.display="none";
}
}
}
//--></script>
Here is my array:
<script type="text/javascript">
<!--
var cityArray = NewArray();
cityArray[0] = "Alameda";
cityArray[1] = "Albany";
cityArray[2] = "Berkeley";
cityArray[3] = "Castro Valley";
cityArray[4] = "Dublin";
cityArray[5] = "Emeryville";
cityArray[6] = "Fremont";
cityArray[7] = "Hayward";
cityArray[8] = "Kensington";
cityArray[9] = "Livermore";
cityArray[10] = "Mount Eden";
cityArray[11] = "NAS Alameda";
cityArray[12] = "Newark";
cityArray[13] = "Oakland";
cityArray[14] = "Piedmont";
cityArray[15] = "Pleasanton";
-->
</script>
Anyone's help would be much appreciated!!!