function onButtonClick() { getColors($get("make").value, $get("model").value); } function fillOptionsList(selectId, result){ // get the HTML select list to fill with option elements var selectList = document.getElementById(selectId); // clear the select list's options selectList.options.length = 0; //add the options from the web server method's results for (var i=0; i < result.length; i++) { var option = new Option(result[i], result[i]); selectList.options.add(option); } } function getColors(make, model){ CarService.GetColors(make, model, onGetColorsSuccess, onFail); } function onGetColorsSuccess(result) { fillOptionsList("color", result); } function onFail(result) { alert(result.get_message()); }