ajax傳值

<select name="sel_branch" id="sel_branch" style="width:120px"  onChange="getEmpInfo(this.value)">
  <%// out.print(HtmlUtil.getOption(branchInfoIt,team_id));%>
    <option value="">--請選擇--</option>
<%
            for(int j=1; j<branchInfoIt.length; j++){
         %>
     <option value="<%=branchInfoIt[j][0] %>">
              <%=branchInfoIt[j][1] %>
     </option>
          <%} %>
  </select>
function getEmpInfo(pro){
var url='./spEmpSelController.do';
var pars='action=gainEmpName1&branchId='+pro;
var myAjax = new Ajax.Request( url, {method: 'post', parameters: pars, onComplete: show_empinfo});
}

function show_empinfo(originalRequest) {
    var result = originalRequest.responseTEXT;
    var t = result.split(';');
    var seloption="";
   
    seloption="sel_emp";  
    document.getElementById(seloption).options.length = 0;
    document.getElementById(seloption).options[document.getElementById(seloption).options.length] = new Option("請選擇", "0", true, false);
    for (i = 1; i < t.length; i++) {
        if(t[i].length>0){
        var trial=t[i].split(',');
            document.getElementById(seloption).options[document.getElementById(seloption).options.length] = new Option(trial[1], trial[0]);
}
    }
}

你可能感兴趣的:(Ajax)