Wordpress Themes - Find services - Debt Consolidation - Insurance Quotes - Internet Dating

PDA

View Full Version : Hello everyone!! Can I get some coding help here?


id4382
Jan 31st 2008, 10:08 am
Ok, so here is what i want to do, I will admit, I am a beginner at javascript so please go easy on me. I am wanting a javascript that will hide based off of what result is returned by another javascript. Here are the code snippets:

GEOCity:

<script language="JavaScript" src="http://j.maxmind.com/app/geoip.js"></script>

<script language="JavaScript">document.write(geoip_city());</script>

Text Hide:

<script type="text/javascript" language="Javascript">

var list = document.getElementsByTagName("font");
for (var i=0; i < list.length; i++) {
if (list[i].innerHTML.indexOf("Members Price:") > -1) {
list[i++].style.display="none";
if (list[i].innerHTML.indexOf("$") > -1) list[i].style.display="none";
}
}
//-->
</script>

The two codes seperately work fine right at this moment. What I want to be able to do, is set a restriction that the the 'Text Hide' code will only run IF a certain City is returned by the 'GEOCity' code. If anyone could help me on this I would be a great help!!!

mnn888
Jan 31st 2008, 12:14 pm
<script type="text/javascript" language="Javascript">

if( geoip_city() == "Certain City"){
HideText();
}

function HideText(){
var list = document.getElementsByTagName("font");
for (var i=0; i < list.length; i++) {
if (list[i].innerHTML.indexOf("Members Price:") > -1) {
list[i++].style.display="none";
if (list[i].innerHTML.indexOf("$") > -1) list[i].style.display="none";
}
}
}
//-->
</script>

id4382
Jan 31st 2008, 1:37 pm
Thanks Mnn, I pasted the code and have ran a few tests, and it is working great! To include additional cities, all I need is to add with a comma to seperate? Or is there an additional arrangement of code to tell it to watch for others?

mnn888
Feb 1st 2008, 6:54 am
Thanks Mnn, I pasted the code and have ran a few tests, and it is working great! To include additional cities, all I need is to add with a comma to seperate? Or is there an additional arrangement of code to tell it to watch for others?

to include additional cities:
var city = geoip_city() ;
if( city == "Certain City" || city == "Certain City2" || city == "Certain City3"){
HideText();
}