需求:用户添加角色时,需要添加兼职。兼职角色,动态添加。角色信息从数据库中读取。
前台代码:动态添加
<div title="兼职">
<div id="divAddElseRole">
<div style="margin-top: 10px;">
<label style="margin-left: 55px;">所属组织:</label>
<label id="currentAddOrganization">教育学院</label>
<label style="margin-left: 85px;">当前角色:</label>
<label id="currentAddRole">管理员</label>
<a href="#" class="easyui-linkbutton" style="margin-left: 90px;" data-options="plain:true" οnclick="AddElseRole()">【添加兼职】</a>
<hr />
</div>
</div>
</div>
//添加用户时,添加兼职
function AddElseRole() {
//获得现有的下拉框
var ElseRoles = document.getElementsByClassName("selectElseRoles");
//如果没有下拉框,则select从0开始编号
var roleData;
var message = document.getElementById("WarnMessage");
if (ElseRoles.length == 0) {
$("#divAddElseRole").append("<div style='margin-top:5px;margin-bottom:5px;'><label style='margin-left:60px;'>兼职角色</label> <select class='selectElseRoles' id ='selectElseRole1' style='width:134px;height:20px;margin-left:110px;'