function pais(X){
/*Array de paises*/
var ar = ["Argentina","Bolivia","Ecuador","Venezuela"];
//Ubicamos el valor del atributo name del enlace en el array y si existe lo cargamos en la variable
var index = $.inArray( $("a[id="+X+"]").attr('name'),ar );
//verificamos que la variable sea mayor, ya que en el array los index inician en 0
if(index > -1){
//si es mayor cargamos el resultado en el campo
$("input[name=pais]").val($("a[id="+X+"]").attr('name'))
}else{
//si no alertamos al usuario
alert("El pais no se encuentra")
}
}
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Fiddle Pages
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Get Fiddle Pages with PRO
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.