...

View Full Version : How to make this array work with FireFox?



klturi421
12-15-2010, 04:49 PM
How would I go about having this work for Firefox. Is there away to have JQuery work with it?


<script type="text/javascript">
region=[//2 dimensional array containing area codes and region pairs
["201","nj"],
["202","dc"],
]


function getRegion(code){
index=0;
while(true){
console.log(index);
if(region[index][0]==code){
return(region[index][1]);
}
index++;
if(index>=region.length){
return(undefined);
}
}
}

function getLocation(number){
out=document.getElementById('output');
var answer;
if(number.length<3){
return(void(0));
}
else{
var code=number.substring(0,3);
answer=getRegion(code)
if(answer==undefined){
out.innerText="unknown area code";
}
else{
out.innerText=answer;
}
}
}
</script>
...
<form>
<input type="text" id="number" onkeyup="getLocation(this.value)">
</form>
<div id="output">
</div>

TinyScript
12-15-2010, 08:03 PM
<script type="text/javascript">
region=[//2 dimensional array containing area codes and region pairs
["201","nj"],
["202","dc"],
]


function getRegion(code){
index=0;
var text=null;

while(region[index]){
//console.log(index)
if(region[index][0]==code){
text=(region[index][1]);
}
index++;

}
return text
}

function getLocation(number){
out=document.getElementById('output');
var answer;
if(number.length<3){
return(void(0));
}
else{
var code=number.substring(0,3);
answer=getRegion(code)
if(answer==undefined){

out.innerHTML="unknown area code";
}
else{
out.innerHTML=answer;
}
}
}

</script>
...
<form>
<input type="text" id="number" onchange="getLocation(this.value)">
</form>
<div id="output">
</div>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum