jsp页面传值给下拉列调用回调函数?

毕加索5481 发布于 2016/09/02 10:17
阅读 146
收藏 0

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("<option selected='selected' value='"+ids[i]+"'>"+names[i]+"</option>");
}
}
}
}
}


页面部分:

<td nowrap="nowrap">
     <html:hidden property="otheroccureddepartid" styleId="otheroccureddepartid"/>
     <html:hidden property="otheroccureddepartname" styleId="otheroccureddepartname"/>
 <html:select property="other_organkey" size="6"  multiple="multiple" styleClass="required"  style="width:150px"> 
   <html:options collection="orgMap" property="label" labelProperty="value" />
 </html:select>
 <a  class="opera_btn" href="javascript:void(0);"  id="seid_otheroccureddepartid"><em><b class="btn_checkmore">多选</b></em></a>
 <a  class="opera_btn" href="javascript:void(0);"  id="deid_otheroccureddepartid"><em><b class="btn_delete">删除</b></em></a>


</tr>


第一张图片为:页面传值过来的图片(页面传值过来部门的排列也要和第二张图片一样),

第二张图片为:点击多选过的页面(要求是这样)


各位大神处处主意

加载中
0
whatwhowhy
whatwhowhy
ul  li处理呗
0
whatwhowhy
whatwhowhy
或者页面加载的时候自动调用一下多选方法
返回顶部
顶部