<%@ page language="java" pageEncoding="UTF-8"%> <!DOCTYPE HTML> <html> <head> <title>审批配置</title> <%@ include file="../common/header.jsp"%> <style type="text/css"> body { height: 100%; overflow: hidden; margin: 0px; padding: 0px; } </style> </head> <body> <form id="fm" method="post" style="margin-left: 20px"> <div style="margin-top: 10px"> <input id='id' name="id" hidden="true" style="display: none;"> </div> <input id="name_old" style="display: none"> <div style="margin-bottom: 10px; margin-left: 80px;"> <span style="color: red;">*</span>政府名称:<select name="governmentid" id="governmentid" class="easyui-combobox" style=" 135px;"></select> </div> <div style="margin-bottom: 10px; margin-left: 85px;"> 审批流程: <span>发起人(全部人员)</span> </p> </div> <div style="margin-bottom: 10px; margin-left: 146px;"> <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" id="AddMoreFileBox" class="removeclass">添加审批人</a></span> </p> </div> <div id="InputsWrapper"> <!-- <div style="margin-bottom: 10px; margin-left: 140px;"> <select name="mytext[]" id="field_1" style="85px;height:25px;"/><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="removeclass"><input type='button' value='删除'></a> </div> --> </div> <div style="margin-bottom: 10px; margin-left: 72px;"> <span style="color: red;">*</span>最终审批人:<select name="lastPersonnel" id="lastPersonnel" class="easyui-combobox" style=" 135px;"></select> </div> <div class="float_div"> <div class="text_input_button_float button_margin" onclick="javascript:saveGovernment();">保存</div> <div class="text_input_button_float button_margin" onclick="javascript:$('#updateW').window('close');">取消</div> </div> </form> <script type="text/javascript"> $(function(){ $('#governmentid').combobox({ url: '<%=request.getContextPath()%>/government/getgovernmentAll', editable : false, valueField : 'id', textField : 'governmentname', onSelect:function(obj) { $('#field_1').combobox({ url: '<%=request.getContextPath()%>/government/getGovernmentPersonnel?governmentid='+obj.id, editable: false, valueField: 'id', textField: 'name' }); $('#lastPersonnel').combobox({ url: '<%=request.getContextPath()%>/government/getGovernmentPersonnel?governmentid='+obj.id, editable: false, valueField: 'id', textField: 'name' }); } }); }); $(document).ready(function() { var MaxInputs = 4; //maximum input boxes allowed var InputsWrapper = $("#InputsWrapper"); //Input boxes wrapper ID var AddButton = $("#AddMoreFileBox"); //Add button ID var x = InputsWrapper.length; //initlal text box count var FieldCount=1; //to keep track of text box added $(AddButton).click(function (e) //on add input button click { if(x <= MaxInputs) //max input box allowed { FieldCount++; //text box added increment //add input box $(InputsWrapper).append('<div style="margin-bottom: 10px; margin-left: 140px;"><select name="mytext[]" style="85px;height:25px;" class="easyui-combobox" id="field_'+ FieldCount +'"/><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="removeclass"><input type="button" value="删除"></a></div>'); x++; //text box increment var m =$("#governmentid").combobox("getValue"); $('#field_'+ FieldCount +'').combobox({ url: '<%=request.getContextPath()%>/government/getGovernmentPersonnel?governmentid='+m, editable: false, valueField: 'id', textField: 'name' }); } return false; }); $("body").on("click",".removeclass", function(e){ //user click on remove text if( x > 1 ) { $(this).parent('div').remove(); //remove text box x--; //decrement textbox } return false; }) }); </script> </body> </html>
<html> <head> <meta charset="utf-8"> <title>动态创建按钮</title> <script src='http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js'></script> </head> <body> <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" id="AddMoreFileBox" class="btn btn-info">添加更多的input输入框</a></span></p> <div id="InputsWrapper"> <div><input type="text" name="mytext[]" id="field_1" value="Text 1"/><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="removeclass"><input type='button' value='删除'></a></div> </div> <script> $(document).ready(function() { var MaxInputs = 8; //maximum input boxes allowed var InputsWrapper = $("#InputsWrapper"); //Input boxes wrapper ID var AddButton = $("#AddMoreFileBox"); //Add button ID var x = InputsWrapper.length; //initlal text box count var FieldCount=1; //to keep track of text box added $(AddButton).click(function (e) //on add input button click { if(x <= MaxInputs) //max input box allowed { FieldCount++; //text box added increment //add input box $(InputsWrapper).append('<div><input type="text" name="mytext[]" id="field_'+ FieldCount +'" value="Text '+ FieldCount +'"/><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="removeclass"><input type="button" value="删除"></a></div>'); x++; //text box increment } return false; }); $("body").on("click",".removeclass", function(e){ //user click on remove text if( x > 1 ) { $(this).parent('div').remove(); //remove text box x--; //decrement textbox } return false; }) }); </script> </body> </html>