/*
 通过首字母获得港口列表的ajax调用。
 paramters:
   firstalpha：首字母
   selectid：显示港口列表的下拉列表的id
 example:
   getdports('M', 'discharge_port');
   getdports(this.getValue(), 'discharge_port');
 */

function getdports(firstalpha, selectid)
{
       var url = "/ajax/discharge/index/firstalpha/"+encodeURIComponent(firstalpha);

       var jSonRequest = new Json.Remote(url, {onComplete: function(list){
           if (false == (list instanceof Object)){
               throw new Error("Ajax 返回的对象不正确，请检查参数、相应的服务器端程序。");
           }
           $(selectid).length = 0;
           var option = new Option('请选择', null);
           $(selectid).options.add(option);
           for(i=0;i<list.length;i++){
               var option = new Option(list[i][0],list[i][1]);
               $(selectid).options.add(option);
           }
       }}).send(null);
}
