function clearSelectByID(selectID) {
    var selectList = document.getElementById(selectID);
    selectList.length = 0;
}

//Step 1: Define an action function make the Ajax request:
function ajax_populateCitySelect(provinceSelectID,citySelectID) {
    var provinceSelectIndex = document.getElementById(provinceSelectID).selectedIndex;
    var provinceID = document.getElementById(provinceSelectID)[provinceSelectIndex].value;
    var poststr="provinceID="+provinceID+"&provinceSelectID="+provinceSelectID+"&citySelectID="+citySelectID;
    ajaxpack.postAjaxRequest("ajq/ajq_populateCitySelect.php", poststr, processGetPost, "txt");
}

//custom function
function ajax_buildCitySelect(targetDiv,targetDivSuburb,provinceSelectID,citySelectID,suburbSelectID,citySelectAttributes,suburbSelectAttributes) {
    var provinceSelectIndex = document.getElementById(provinceSelectID).selectedIndex;
    var provinceID = document.getElementById(provinceSelectID)[provinceSelectIndex].value;
    var poststr="targetDiv="+targetDiv+"&targetDivSuburb="+targetDivSuburb+"&provinceID="+provinceID+"&provinceSelectID="+provinceSelectID+"&citySelectID="+citySelectID+"&suburbSelectID="+suburbSelectID+"&citySelectAttr="+citySelectAttributes+"&suburbSelectAttr="+suburbSelectAttributes;

    ajaxpack.postAjaxRequest("ajq/ajq_populateCitySelect.php", poststr, processGetPost, "txt");
}

//Step 2: Define a "callback" function to process the data returned by the Ajax request:
function processGetPost(){
    var myajax      = ajaxpack.ajaxobj;
    var myfiletype  = ajaxpack.filetype;

    if (myajax.readyState == 4){ //if request of file completed
        if (myajax.status==200 || window.location.href.indexOf("http")==-1){ //if request was successful or running script locally

            var provinceSelectID= "";
            var citySelectID    = "";
            var selectOptions   = "";
            eval(myajax.responseText);

            var provinceSelect  = document.getElementById(provinceSelectID);
            var citySelect      = document.getElementById(citySelectID);

            // update city select
            citySelect.innerHTML = citySelectOptions;
        }
    }
}