\core\dynaform\view\country.xml
<script type="text/javascript">
function countryEvent(){
jQuery.ajax({
url : "country.xml",
success : function(xml) {
jQuery(xml).find("country").each(
function() {
var t = jQuery(this).attr("label");
jQuery("#country").append("<option value='"+t+"'>" + t + "</option>");
});
var country = '<s:property value="content.country"/>';
jQuery("#country").val(country);
provinceEvent();
}
});
}
function provinceEvent(){
jQuery("#province>option").remove();
var pname = jQuery("#country").val();
jQuery.ajax({url : "country.xml",
success : function(xml) {
jQuery(xml).find("country[label='"+ pname+ "']>province").each(
function() {
var t = jQuery(this).attr("label");
jQuery("#province").append("<option value='"+t+"'>"+ t+ "</option>");
});
var province = '<s:property value="content.province"/>';
jQuery("#province").val(province);
cityEvent();
}
});
}
function cityEvent(){
jQuery("#city>option").remove();
var pname = jQuery("#province").val();
jQuery.ajax({url : "country.xml",
success : function(xml) {
jQuery(xml).find("province[label='"+ pname+ "']>city").each(
function() {
var t = jQuery(this).attr("label");
jQuery("#city").append("<option value='"+t+"'>"+ t+ "</option>");
});
var city = '<s:property value="content.city"/>';
jQuery("#city").val(city);
townEvent();
}
});
}
function townEvent(){
jQuery("#town>option").remove();
var pname = jQuery("#city").val();
jQuery.ajax({url : "country.xml",
success : function(xml) {
jQuery(xml).find("city[label='"+ pname+ "']>town").each(
function() {
var t = jQuery(this).attr("label");
jQuery("#town").append("<option value='"+t+"'>"+ t+ "</option>");
});
var town = '<s:property value="content.town"/>';
jQuery("#town").val(town);
}
});
}
function initOptions() {
countryEvent();
jQuery("#level").val("4");
var isroute = '<s:property value="content.isroute"/>';
jQuery("#isroute").val(isroute);
jQuery("#country").change(function() {
provinceEvent();
jQuery("#level").val("4");
});
jQuery("#province").change(function() {
cityEvent();
jQuery("#level").val("8");
});
jQuery("#city").change(function() {
townEvent();
jQuery("#level").val("12");
});
}
</script> |