$(document).ready(function() {
$("#toRight").click(function(){
$("#dataForm_pubAddress_source option:selected").each(function(){
$("#dataForm\\.pubAddress").append("<option value=" + $(this).val() + " title=" + $(this).html() + ">" + $(this).html() + "</option>");
$(this).remove();
});
});
$("#toLeft").click(function(){
$("#dataForm\\.pubAddress option:selected").each(function(){
$("#dataForm_pubAddress_source").append("<option value=" + $(this).val() + " title=" + $(this).html() + ">" + $(this).html() + "</option>");//这个方法是默认在后面添加
$(this).remove();
});
});
$('option','#dataForm_pubAddress_source').attr('title',function(){
return this.innerHTML;
});
$('option','#dataForm\\.pubAddress').attr('title',function(){
return this.innerHTML;
});
});
<tr>
<td style="width: 200px;" id="dataForm.pubAddress.label">
地址:<font color="#ff0000">*</font>
</td>
<td>
<table>
<tr>
<td>
<s:select size='8' multiple="true"
id="dataForm_pubAddress_source" cssStyle="width: 360px;height:60px" name="dataForm.pubAddress_source"
list="mpOfficeLocationList" headerKey="" listKey="code" listValue="parmValue">
</s:select>
</td>
<td>
<input type="button" value=" >> " id="toRight" />
<br />
<br />
<input type="button" value=" << " id="toLeft" />
</td>
<td>
<!--
<select size='10' multiple="multiple"
id="dataForm.pubAddress" name="dataForm.pubAddress" style="width: 300px;height:60px">
</select>
-->
<s:select size='8' multiple="true"
id="dataForm.pubAddress" cssStyle="width: 360px;height:60px" name="dataForm.pubAddress"
list="mpOfficeLocationSelectList" headerKey="" listKey="code" listValue="parmValue">
</s:select>
</td>
</tr>
</table>
</td>
</tr>
action中定义变量:
/** 可选地址 */
private List<PbmParamValue> mpOfficeLocationList;
/** 已选地址 */
private List<PbmParamValue> mpOfficeLocationSelectList;