Jump to content
Vally

Ajutor javascript [contra cost]

Recommended Posts

Posted

Asta e codul original.

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

var country = geoip_country_code();

switch (country)
{
case (country = "US"): //Tier1
window.location = "http://google.ro/tier1";
break;
case (country = "GB"): //Tier1
window.location = "http://google.ro/tier1";
break;
case (country = "AU"): //Tier2
window.location = "http://google.ro/tier2";
break;
case (country = "RO"): //Tier2
window.location = "http://google.ro/tier2";
break;
case (country = "DK"): //Tier2
window.location = "http://google.ro/tier2";
break;


default:
window.location = "http://google.ro/restofworld";
break;
}
</script>

As vrea sa arate asa. Sa pot pune mai multe tari pentru o singura locatie. Eu am pus virgula (,) intre codurile tarilor, dar nu funtioneaza.

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

var country = geoip_country_code();

switch (country)
{
case (country = "US,GB"): //Tier1
window.location = "http://google.ro/tier1";
break;
case (country = "AU,RO,DK"): //Tier2
window.location = "http://google.ro/tier2";
break;

default:
window.location = "http://google.ro/restofworld";
break;
}
</script>

Fac donatie paypal, tansfer bancar, cash in craiova.

Posted

Ai incercat asa:


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

var country = geoip_country_code();

switch (country)
{
case "US":
case "GB": //Tier1
window.location = "http://google.ro/tier1";
break;
case "AU":
case "RO":
case "DK": //Tier2
window.location = "http://google.ro/tier2";
break;

default:
window.location = "http://google.ro/restofworld";
break;
}
</script>

Posted (edited)

Ai putea incerca ceva de genul.

<script>

function isInArray(value, array) {

return array.indexOf(value) > -1 ? true : false;

}

var country = geoip_country_code();

if (isInArray(country, ["US", "GB"])) {

window.location = "http://google.ro/tier1";

} else if (isInArray(country, ["AU", "RO", "DK"])) {

window.location = "http://google.ro/tier2";

} else {

window.location = "http://google.ro/restofworld";

}

</script>

Testat.

Edited by GarryOne
Posted

In mod normal pentru switch, nu prea ai cum sa pui cu virgula, si nici nu vad de ce ai face-o. Poti incerca asa cum ti-a sugerat GarryOne dar nu mai folosesti switch ci if-uri.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...