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 %>">
<%=branchInfoIt %>
</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 = new Option("請選擇", "0", true, false);
for (i = 1; i < t.length; i++) {
if(t.length>0){
var trial=t.split(',');
document.getElementById(seloption).options = new Option(trial, trial);
}
}
}
页:
[1]