企业网站模板大全,增城营销网站建设,平台网站的策划设计,wordpress 作者 英文摘要#xff1a;最近项目中用到了jquery#xff0c;ajax#xff0c;由于很长时间没用了#xff0c;所以这次做花了很多时间#xff0c;现在记录一下#xff0c;方便以后回忆#xff1a; 
一#xff1a;js文件#xff1a; script typetext/javascript最近项目中用到了jqueryajax由于很长时间没用了所以这次做花了很多时间现在记录一下方便以后回忆 
一js文件 script typetext/javascript// 进出港显示字段权限分配function jingchugang(){var tableName  $(input:radio:checked).val();$.ajax({type:POST,url:s:url value/u/showFieldSet/,data:tableNametableName,dataType:json,success:function(dataMap){var fieldList  dataMap.fieldList;if(fieldList ! null  fieldList.length  0){//var start  select idselectL nameselectL multiplemultiple;//var str  ;for(var i  0; i fieldList.length; i){//str  trtdinput typecheckbox idfieldName namefieldName/fieldList[i].fieldNametd/tr;//str  option valuefieldList[i].idfieldList[i].fieldName/option;$(option valuefieldList[i].idfieldList[i].fieldName/option).appendTo(#selectL);}//var end  /select;//$(str).appendTo(#selectL);}},});} 
/script 二jsp文件 
tr classeventddiv classselect_sidep待选区/pselect idselectL nameselectL multiplemultiple/select/divdiv classselect_optp idtoright title添加/pp idtoleft title移除/p/divdiv classselect_sidep已选区/pselect idselectR nameselectR multiplemultiple/select/divdiv classsub_btninput typebutton idsub valuegetValue //div/td/tr 三最后我把这个页面附上 % page languagejava contentTypetext/html; charsetUTF-8pageEncodingUTF-8%
% include file../../common/include_tag.jsp%
% include file../../common/page_var.jsp%
!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
html xmlnshttp://www.w3.org/1999/xhtml
head
meta http-equivContent-Type contenttext/html; charsetutf-8 /
title%pageTitle%/title
link hrefs:url value/images/favicon.ico/ relshortcut icontypeimage/x-icon /
% include file../../common/page_head.jsp%
script typetext/javascript$(function() {pilicat.title2div(title2div);pilicat.keysubmit(form1, submit, true);});
/script
script typetext/javascript
$(function(){var leftSel  $(#selectL);var rightSel  $(#selectR);$(#toright).bind(click,function(){		leftSel.find(option:selected).each(function(){$(this).remove().appendTo(rightSel);});});$(#toleft).bind(click,function(){		rightSel.find(option:selected).each(function(){$(this).remove().appendTo(leftSel);});});leftSel.dblclick(function(){$(this).find(option:selected).each(function(){$(this).remove().appendTo(rightSel);});});rightSel.dblclick(function(){$(this).find(option:selected).each(function(){$(this).remove().appendTo(leftSel);});});$(#sub).click(function(){var showFields  [];rightSel.find(option).each(function(){showFields.push(this.value);});showFields  showFields.join(,);if(showFields  ){alert(没有选择任何项);}else{alert(showFields);}});});
/script
script typetext/javascript// 进出港显示字段权限分配function jingchugang(){var tableName  $(input:radio:checked).val();$.ajax({type:POST,url:s:url value/u/showFieldSet/,data:tableNametableName,dataType:json,success:function(dataMap){var fieldList  dataMap.fieldList;if(fieldList ! null  fieldList.length  0){//var start  select idselectL nameselectL multiplemultiple;//var str  ;for(var i  0; i fieldList.length; i){//str  trtdinput typecheckbox idfieldName namefieldName/fieldList[i].fieldNametd/tr;//str  option valuefieldList[i].idfieldList[i].fieldName/option;$(option valuefieldList[i].idfieldList[i].fieldName/option).appendTo(#selectL);}//var end  /select;//$(str).appendTo(#selectL);}},});} 
/script
script typetext/javascript$(document).ready(function() {$(#form1).ajaxForm({dataType : json,beforeSubmit : checkForm,success : afterPost});});function checkForm(formData, jqForm, options) {alert(formData);}function afterPost(responseText, statusText, xhr, $form) {if (responseText.resultStatus  true) {parent.$.jBox.tip(保存成功请刷新查看结果, success, {timeout : 2000});parent.$.jBox.close(true);} else {$.jBox.error(保存失败, 失败信息);}}function submitForm() {getSelectAll();}
/script
style typetext/css
.update {margin: 0 auto;padding: 0;width: 98%;
}.update td {margin: 0;height: 30px;padding: 5px;
}.update .name {text-align: right;
}.title_div {width: 350px;
}body {background: url(s:url value/images/gray_bg.png/) 0 0 repeat-y#F6F6F6;
}
/style
style typetext/css
.select_side {float: left;width: 200px
}select {width: 180px;height: 120px
}.select_opt {float: left;width: 40px;height: 100%;margin-top: 36px
}.select_opt p {width: 26px;height: 26px;margin-top: 6px;background: url(s:url value/images/arr.gif/) no-repeat;cursor: pointer;text-indent: -999em
}.select_opt p#toright {background-position: 2px 0
}.select_opt p#toleft {background-position: 2px -22px
}
/style
/head
bodydiv classrounded tabletable width100% cellpadding0 cellspacing0 border0 classbox_toptbodytrtd classtitle/tdtd/td/tr/tbody/tablediv classerror rounded top_error hideol/olspan/span/divform:form idform1 commandNameroleInfo action${pageContext.request.contextPath}/u/saveRoleShowField methodposttable classupdate cellpadding0 cellspacing1 border0tbodytr classeventd角色名称 ${roleInfo.roleName }input typehidden nameid value${roleInfo.id} /input typehidden  nameshowFields value${showFields} //td/trtr classeventd航班类型c:forEach items${tableNameList} vartableNamec:if test${tableName   TB_CMS_FLGTINFO_D}input typeradio classradio nametableName idTB_CMS_FLGTINFO_D value${tableName } οnclickjingchugang(${tableName}); /出港列表/c:ifc:if test${tableName   TB_CMS_FLGTINFO_A}input typeradio classradio nametableName idTB_CMS_FLGTINFO_A value${tableName } οnclickjingchugang(${tableName});/进港列表/c:if/c:forEach/td/trtr classeventd赋予的显示字段列表/td/tr!-- tr classeventddiv idmenuTree/div/td/tr --tr classeventddiv classselect_sidep待选区/pselect idselectL nameselectL multiplemultiple/select/divdiv classselect_optp idtoright title添加/pp idtoleft title移除/p/divdiv classselect_sidep已选区/pselect idselectR nameselectR multiplemultiple/select/divdiv classsub_btninput typebutton idsub valuegetValue //div/td/tr%-- tr classeventd赋予的显示字段列表/td/trtr classeventdform:checkboxes items${roleShowEntities } pathshowFields itemLabelfieldName itemValueid delimiter//td/tr --%/tbody/tabletable classtable top_linetbodytrtd aligncenter height60a idsubmit classsubmithrefjavascript:; οnclicksubmitForm();保存/a/td/tr/tbody/table/form:form/div
/body
/html