1.情况描述:
这是一个修改的功能:
在java后台往前段传值的时候,有个其他选择部门,部门为横向成列(需求:纵向成列),,怎么搞?
点击选择的时候应为调用了回调函数,所以才纵向成列。
附上代码:
jquery://其他发生部门
$("#otheroccureddepartid").val("<%=orgidInfo%>");//其他发生部门id
$("#otheroccureddepartname").val("<%=orgnameInfo%>");//其他发生部门name
jQuery("#seid_otheroccureddepartid").click(function() {
var val = jQuery(":hidden[name='occuredorgid']").val();
if(val == "") {
dialogAlert("必须先选择机构!");
jQuery("#btn_occuredOrg").focus();
} else {
locate_tree_window('<%=contextPath%>','getDepartmentByUporgankey','forms[0]','otheroccureddepartid,otheroccureddepartname','checkbox','&uporgankey=' + val,'addResDept');
}
});
//其他发生部门删除
$("#deid_otheroccureddepartid").click(function() {
$("select[name='other_organkey'] option:selected").remove();
var ids = "";
var names = "";
$("select[name='other_organkey'] option").each(function(i) {
ids += $(this).val() + ",";
names += $(this).text() + ",";
});
$("#otheroccureddepartid").val(ids.substr(0, ids.length - 1));
$("#otheroccureddepartname").val(names.substr(0, names.length - 1));
});
//其它发生部门回调函数
function addResDept() {
var ids = $("#otheroccureddepartid").val().split(",");
var names = $("#otheroccureddepartname").val().split(",");
if ($("#otheroccureddepartid").val() != "") {
var errorElement = $("select[name='other_organkey']").next(
"LABEL.error:first");
$(errorElement).remove();
}
if ($("#otheroccureddepartid").val() != "") {
$("select[name='other_organkey']").empty();
if (ids.length == names.length) {
for ( var i = 0; i < ids.length; i++) {
if ($("select[name='other_organkey']").find("option[value='" + ids[i] + "']").val() == undefined) {
$("select[name='other_organkey']").append(""+names[i]+"");
}
}
}
}
}
页面部分:
/html:select
多选
删除
第一张图片为:页面传值过来的图片(页面传值过来部门的排列也要和第二张图片一样),
第二张图片为:点击多选过的页面(要求是这样)