function validate_exist(lista,id_seach)
{
var ind;
for(ind=0; ind<lista.length; ind++)
{
if (lista[ind] == id_seach)
{
return true;
}
else
{
return false;
}
break;
}
}
function filter_selected(obj)
{
location_array = new Array();
country = new Array();
province = new Array();
city = new Array();
{/literal}
{section name=i loop=$location}
location_array[{$smarty.section.i.index}]= new Array();
location_array[{$smarty.section.i.index}]["country"]='{$location[i].country}';
location_array[{$smarty.section.i.index}]["city"]='{$location[i].city}';
location_array[{$smarty.section.i.index}]["province"]='{$location[i].province}';
location_array[{$smarty.section.i.index}]["id"]='{$location[i].id}';
location_array[{$smarty.section.i.index}]["name"]="{$location[i].name}";
{/section}
{section name=i loop=$country}
country[{$smarty.section.i.index}]= new Array();
country[{$smarty.section.i.index}]["id"]={$country[i].id};
country[{$smarty.section.i.index}]["name"]="{$country[i].name}";
{/section}
{section name=i loop=$province}
province[{$smarty.section.i.index}]= new Array();
province[{$smarty.section.i.index}]["id"]={$province[i].id};
province[{$smarty.section.i.index}]["name"]="{$province[i].name}";
{/section}
{section name=i loop=$city}
city[{$smarty.section.i.index}]= new Array();
city[{$smarty.section.i.index}]["id"]={$city[i].id};
city[{$smarty.section.i.index}]["name"]="{$city[i].name}";
{/section}
{literal}
if(obj.id=="country")
{
if(obj.value!="0"){
province_new = new Array();
city_new = new Array();
location_new = new Array();
for(i=0; i<location_array.length; i++)
{
loc=location_array[i];
if(loc["country"]==obj.value )
{
for(j=0; j<province.length; j++)
{
pro=province[j];
if(pro["id"]==loc["province"])
{
if(!validate_exist(province[j],loc["province"]))
province_new.push(pro);
}
}
for(j=0; j<city.length; j++)
{
cit=city[j];
if(cit["id"]==loc["city"])
city_new.push(cit);
}
for(j=0; j<location_array.length; j++)
{
loc1=location_array[j];
if(loc1["id"]==loc["id"])
location_new.push(loc1);
}
}
}
province_html="<option value='0'>Geen voorkeur</option>";
city_html="<option value='0'>Geen voorkeur</option>";
location_html="<option value='0'>Geen voorkeur</option>";
for(j=0; j<province_new.length; j++)
{
pro=province_new[j];
province_html+="<option value='"+pro['id']+"'>"+pro['name']+"</option>";
}
document.getElementById("province").innerHTML=province_html;
for(j=0; j<city_new.length; j++)
{
cit=city_new[j];
city_html+="<option value='"+cit['id']+"'>"+cit['name']+"</option>";
}
for(j=0; j<location_new.length; j++)
{
lo=location_new[j];
location_html+="<option value='"+lo['id']+"'>"+lo['name']+"</option>";
}
document.getElementById("city").innerHTML=city_html;
document.getElementById("location_id").innerHTML=location_html;
}
else
{
province_html="<option value='0'>Geen voorkeur</option>";
city_html="<option value='0'>Geen voorkeur</option>";
location_html="<option value='0'>Geen voorkeur</option>";
for(j=0; j<province.length; j++)
{
pro=province[j];
province_html+="<option value='"+pro['id']+"'>"+pro['name']+"</option>";
}
document.getElementById("province").innerHTML=province_html;
for(j=0; j<city.length; j++)
{
cit=city[j];
city_html+="<option value='"+cit['id']+"'>"+cit['name']+"</option>";
}
for(j=0; j<location_array.length; j++)
{
lo=location_array[j];
location_html+="<option value='"+lo['id']+"'>"+lo['name']+"</option>";
}
document.getElementById("city").innerHTML=city_html;
document.getElementById("location_id").innerHTML=location_html;
}
}
if(obj.id=="province")
{
if(obj.value!="0"){
city_new = new Array();
location_new = new Array();
for(i=0; i<location_array.length; i++)
{
loc=location_array[i];
if(loc["province"]==obj.value )
{
for(j=0; j<city.length; j++)
{
cit=city[j];
if(cit["id"]==loc["city"])
city_new.push(cit);
}
for(j=0; j<location_array.length; j++)
{
loc1=location_array[j];
if(loc1["id"]==loc["id"])
location_new.push(loc1);
}
}
}
city_html="<option value='0'>Geen voorkeur</option>";
location_html="<option value='0'>Geen voorkeur</option>";
for(j=0; j<city_new.length; j++)
{
cit=city_new[j];
city_html+="<option value='"+cit['id']+"'>"+cit['name']+"</option>";
}
for(j=0; j<location_new.length; j++)
{
lo=location_new[j];
location_html+="<option value='"+lo['id']+"'>"+lo['name']+"</option>";
}
document.getElementById("city").innerHTML=city_html;
document.getElementById("location_id").innerHTML=location_html;
}
else
{
city_html="<option value='0'>Geen voorkeur</option>";
location_html="<option value='0'>Geen voorkeur</option>";
for(j=0; j<city.length; j++)
{
cit=city[j];
city_html+="<option value='"+cit['id']+"'>"+cit['name']+"</option>";
}
for(j=0; j<location_array.length; j++)
{
lo=location_array[j];
location_html+="<option value='"+lo['id']+"'>"+lo['name']+"</option>";
}
document.getElementById("city").innerHTML=city_html;
document.getElementById("location_id").innerHTML=location_html;
}
}
if(obj.id=="city")
{
if(obj.value!="0"){
location_new = new Array();
for(i=0; i<location_array.length; i++)
{
loc=location_array[i];
if(loc["city"]==obj.value )
{
for(j=0; j<location_array.length; j++)
{
loc1=location_array[j];
if(loc1["id"]==loc["id"])
location_new.push(loc1);
}
}
}
location_html="<option value='0'>Geen voorkeur</option>";
for(j=0; j<location_new.length; j++)
{
lo=location_new[j];
location_html+="<option value='"+lo['id']+"'>"+lo['name']+"</option>";
}
document.getElementById("location_id").innerHTML=location_html;
}
else
{
location_html="<option value='0'>Geen voorkeur</option>";
for(j=0; j<location_array.length; j++)
{
lo=location_array[j];
location_html+="<option value='"+lo['id']+"'>"+lo['name']+"</option>";
}
document.getElementById("location_id").innerHTML=location_html;
}
}
}