jquery 동적 추가/삭제tr/td
131485 단어 jquery
1 <head runat="server">
2 <title></title>
3 <!--easyui -->
4 <link rel="stylesheet" type="text/css" href="../../script/jquery-easyui-1.3.2/themes/icon.css" />
5 <link rel="stylesheet" type="text/css" href="../../script/easy_ui/themes/demo.css" />
6 <link rel="stylesheet" type="text/css" href="../../script/jquery-easyui-1.3.2/themes/default/easyui.css" />
7 <link href="../../css/function.css" rel="stylesheet" type="text/css" />
8 <script type="text/javascript" src="../../script/jquery-1.8.2.js"></script>
9 <script type="text/javascript" src="../../script/jquery-easyui-1.3.2/locale/easyui-lang-zh_TW.js"></script>
10 <script type="text/javascript" src="../../script/jquery-easyui-1.3.2/jquery.easyui.min.js"></script>
11 <script type="text/javascript" src="../../script/jquery-easyui-1.3.2/locale/easyui-lang-zh_CN.js"></script>
12 <!-- -->
13 <link href="../../css/images/style.css" rel="stylesheet" type="text/css" />
14 <script type='text/javascript' src="../../script/swfupload/swfupload.js"></script>
15 <script type='text/javascript' src="../../script/swfupload/swfupload.queue.js"></script>
16 <script type="text/javascript" src="../../script/swfupload/swfupload.handlers.js"></script>
17 <script src="../../script/jquery.form.min.js" type="text/javascript"></script>
18 <script type="text/javascript" src="../../script/function.js"></script>
19 <!-- -->
20 <script type="text/javascript" charset="utf-8" src="../../editor/kindeditor-min.js"></script>
21 <script type="text/javascript" charset="utf-8" src="../../editor/lang/zh_CN.js"></script>
22 <script type="text/javascript">
23 /* jquery easyui */
24 window.onload = function () {
25 InitGird();
26 }
27 //
28 var editor;
29 $(function () {
30 editor = KindEditor.create('textarea[name="Describe"]', {
31 resizeType: 1,
32 uploadJson: '../ashx/upload_ajax.ashx?action=EditorFile&IsWater=1',
33 fileManagerJson: '../ashx/upload_ajax.ashx?action=ManagerFile',
34 allowFileManager: true
35 });
36 });
37 //
38 $(function () {
39 InitSWFUpload("../ashx/upload_ajax.ashx", "Filedata", "1024 KB", "../../script/swfupload/swfupload.swf", 1, 1);
40 });
41 //
42 function Search() {
43 $('#dgCaseInfo').datagrid('load', {
44 action: "loadListPage",
45 Names: $("#Names").val()
46 });
47 }
48 //
49 function InitGird() {
50 $("#dgCaseInfo").datagrid({
51 autoRowHeight: false,
52 loadMsg: ' ...',
53 url: '../ashx/GetSm_CaseInformation.ashx?types=loadListPage', //
54 sortName: 'ID', //
55 idField: 'ID', // ,
56 iconCls: '', //
57 singleSelect: true,
58 width: '100%', //
59 height: 'auto', //
60 nowrap: true, // ,True
61 striped: true, //True
62 collapsible: false, //
63 sortOrder: 'desc', //
64 remoteSort: true, //
65 fit: true,
66 singleSelect: true, //
67 selectOnCheck: false, //
68 fitColumns: true, //
69 columns: [[
70 { field: 'Name', title: ' ', width: 200, align: 'left' },
71 { field: 'Add_Time', title: ' ', width: 100, align: 'left' },
72 { field: 'Describe', title: ' ', width: 100, align: 'left', hidden: true },
73 { field: 'FilePath', title: ' ', width: 100, align: 'left',
74 formatter: function (value, row, index) {
75 if (row.FilePath != "") {
76 return '<a href=javascript:ShowBigview(' + index + ')><img alt=" " src="../..' + row.FilePath + '"width="100px" height="25px"/></a>'
77 } else {
78 return " "
79 }
80 }
81 },
82 { field: 'Flag', title: ' ', width: 100, align: 'left',
83 formatter: function (value, row, index) {
84 if (row.Flag == 0) {
85 return " ";
86 } else {
87 return " ";
88 }
89 }
90 },
91 { field: 'TypeID', title: ' ', width: 100, align: 'left', hidden: true },
92 { field: 'MonadID', title: ' ', width: 100, align: 'left', hidden: true },
93 { field: 'MonadName', title: ' ', width: 100, align: 'left', hidden: true }
94 ]],
95 toolbar: "#toolbar",
96 queryParams: { "action": "query" },
97 pagination: true, //
98 pagePosition: 'bottom', //
99 pageNumber: 1, //
100 pageSize: 10, //
101 onDblClickRow: function (rowIndex, rowData) {//
102 Edit();
103 }
104 })
105 }
106 var url;
107 //
108 function Add() {
109 $("#tdLeft").remove();// td
110 $("#tdSeckill").remove(); // td
111 loadTypeID();
112 editor.html("");
113 $('#dlg').dialog('open').dialog('setTitle', ' ');
114 $('#form1').form('clear');
115 url = '../ashx/GetSm_CaseInformation.ashx?types=ListAdd';
116 $("input[name='Flag']").eq(0).attr('checked', 'true');
117 }
118 //
119 function Edit() {
120 $("#tdLeft").remove(); // td
121 $("#tdSeckill").remove(); // td
122 loadTypeID();
123 url = '../ashx/GetSm_CaseInformation.ashx?types=ListEdit';
124 var row = $('#dgCaseInfo').datagrid('getSelected');
125 if (row) {
126 $('#dlg').dialog('open').dialog('setTitle', ' ');
127 $("#imageCaseUrl").attr("src", "../.." + $('#FilePath').val()); // <image id="imageCaseUrl"> url
128 editor.html(row["Describe"]);
129 if (row["IsSeckill"]==1)// :
130 { 131 $("#trSeckill").append(' <td id="tdLeft" class="tab_td_right" style="width:80px;"> :</td><td id="tdSeckill" class="tab_td_left"><input id="SeckillDateBegin" class="easyui-datetimebox" name="SeckillDateBegin" style="width:150px"> <input id="SeckillDateEnd" class="easyui-datetimebox" name="SeckillDateEnd" style="width:150px"></td>') 132 // easyui
133 $('#SeckillDateBegin').datetimebox({ 134 required: true, 135 showSeconds: false
136 }); 137 $('#SeckillDateEnd').datetimebox({ 138 required: true, 139 showSeconds: false
140 }); 141 } 142 $('#form1').form('load', row); 143 $("#Flag ").val(row["Flag"]); //
144 } 145 }
146 //
147 function Save() {
148 editor.sync();
149 $('#form1').form('submit', {
150 url: url,
151 onSubmit: function () {
152 return $(this).form('validate');
153 },
154 success: function (result) {
155 if (result <= 0) {
156 $.messager.show({
157 title: 'Error',
158 msg: result.errorMsg
159 });
160 } else {
161 $('#dlg').dialog('close'); // close the dialog
162 $('#dgCaseInfo').datagrid('reload'); // reload the user data
163 }
164 }
165 });
166 }
167 //
168 function destroy() {
169 var row = $('#dgCaseInfo').datagrid('getSelected');
170 if (row) {
171 $.messager.confirm(' ', ' ?', function (r) {
172 if (r) {
173
174 $.post('../ashx/GetSm_CaseInformation.ashx?types=ListDel',
175 { id: row.ID },
176 function (result) {
177 if (result > 0) {
178 $('#dgCaseInfo').datagrid('reload'); // reload the user data
179 } else {
180 $.messager.show(
181 { // show error message
182 title: 'Error',
183 msg: result.errorMsg
184 }
185 );
186 }
187 }, 'json');
188 }
189 });
190 }
191 }
192 //
193 function loadTypeID() {
194 $('#TypeID').combobox({
195 url: '../ashx/GetSm_CaseInformation.ashx?types=TypeIDLoad',
196 valueField: 'ID',
197 textField: 'DtyName'
198 });
199 }
200 //
201 function ShowBigview(rowIndex) {
202 var row = $("#dgCaseInfo").datagrid('getRows')[rowIndex];
203 if (row["FilePath"].toString() != "") {
204 $.messager.alert(' ', '<img alt="" src=../..' + row["FilePath"] + ' width="100px" height="100px" />');
205 } else {
206 $.messager.alert(' ', ' !');
207 }
208 }
209 //
210 function DisDate() { 211 $("#tdLeft").remove(); // td
212 $("#tdSeckill").remove(); // td
213 } 214 //
215 function HideDate() { 216 $("#tdLeft").remove(); // td
217 $("#tdSeckill").remove(); // td
218 $("#trSeckill").append(' <td id="tdLeft" class="tab_td_right" style="width:80px;"> :</td><td id="tdSeckill" class="tab_td_left"><input id="SeckillDateBegin" class="easyui-datetimebox" name="SeckillDateBegin" style="width:150px"> <input id="SeckillDateEnd" class="easyui-datetimebox" name="SeckillDateEnd" style="width:150px"></td>') 219 // easyui
220 $('#SeckillDateBegin').datetimebox({ 221 required: true, 222 showSeconds: false
223 }); 224 $('#SeckillDateEnd').datetimebox({ 225 required: true, 226 showSeconds: false
227 });
228 }
229 </script>
230
231 </head>
232 <body>
233 <table id="dgCaseInfo">
234 </table>
235 <div id="toolbar" style="width: 100%">
236 <div style="padding-top: 5px; width: 100%">
237 <a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-add" plain="true"
238 onclick="Add()"> </a> <a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-edit"
239 plain="true" onclick="Edit()"> </a> <a href="javascript:void(0)" class="easyui-linkbutton"
240 iconcls="icon-remove" plain="true" onclick="destroy()"> </a>
241 </div>
242 :<input id="Names" name="Names" class="easyui-validatebox" type="text" />
243 <a id="search" href="#" onclick="Search()" class="easyui-linkbutton" plain="true"
244 data-options="iconCls:'icon-search'"> </a>
245 </div>
246 <div id="dlg" class="easyui-dialog" style="width:800px; height: 400px; padding: 10px;"
247 closed="true" buttons="#dlg-buttons">
248 <div class="ftitle">
249 </div>
250 <form id="form1" runat="server" method="post">
251 <table id="table_edit" class="tab" style="width: 98%; font-size: 12px; border: 1px #E1E1E1 solid" cellpadding="0"
252 cellspacing="1">
253 <tr class="tab_tr" style="display: none;">
254 <td colspan="4">
255 <input name="ID" class="easyui-validatebox" />
256 <input name="MonadID" class="easyui-validatebox" />
257 </td>
258 </tr>
259 <tr style="height: 26px;" class="tab_tr">
260 <td class="tab_td_right" style="width:80px;">
261 :
262 </td>
263 <td class="tab_td_left">
264 <input name="Name" class="easyui-validatebox" required="true" style="width:150px" />
265 </td>
266 <td class="tab_td_right" style="width:80px;">
267 :
268 </td>
269 <td class="tab_td_left">
270 <input id="TypeID" name="TypeID" style="width: 200px" required="true" />
271 </td>
272 </tr>
273 <tr style="height: 26px; " class="tab_tr">
274 <td class="tab_td_right" style="width:80px;">
275 :
276 </td>
277 <td class="tab_td_left">
278 <input name="Price" class="easyui-validatebox" required="true" style="width: 150px" />
279 </td>
280 <td class="tab_td_right" style="width:80px;">
281 :
282 </td>
283 <td class="tab_td_left">
284 <input id="Discount" name="Discount" style="width: 200px" />
285 </td>
286 </tr>
287 <tr style="height: 26px; " class="tab_tr">
288 <td class="tab_td_right" style="width:80px;">
289 :
290 </td>
291 <td class="tab_td_left">
292 <input id="InventoryNumber" name="InventoryNumber" style="width: 150px" />
293 </td>
294 <td class="tab_td_right" style="width:80px;">
295 :
296 </td>
297 <td class="tab_td_left">
298 <input id="SellNumber" name="SellNumber" style="width: 200px" />
299 </td>
300 </tr>
301 <tr style="height: 26px; " class="tab_tr">
302 <td class="tab_td_right" style="width:80px;">
303 :
304 </td>
305 <td class="tab_td_left">
306 <input name="Flag" type="radio" value="0" />   
307 <input name="Flag" type="radio" value="1" />
308 </td>
309 <td class="tab_td_right" style="width:80px;">
310 :
311 </td>
312 <td class="tab_td_left">
313 <input name="IsHotSell" type="radio" value="0" />   
314 <input name="IsHotSell" type="radio" value="1" />
315 </td>
316 </tr>
317 <tr style="height: 26px; " class="tab_tr" id="trSeckill">
318 <td class="tab_td_right" style="width:80px;">
319 :
320 </td>
321 <td class="tab_td_left" >
322 <input name="IsSeckill" type="radio" value="0" onclick="DisDate()"/>   
323 <input name="IsSeckill" type="radio" value="1" onclick="HideDate()"/>
324 </td>
325 <%-- <td class="tab_td_left" >
326 <input id="SeckillDateBegin" disabled="disabled" class="easyui-datetimebox" name="SeckillDateBegin" data-options="required:true,showSeconds:false" style="width:150px">
327 <input id="SeckillDateEnd" disabled="disabled" class="easyui-datetimebox" name="SeckillDateEnd" data-options="required:true,showSeconds:false" style="width:150px">
328 </td>--%>
329 </tr>
330
331 <tr style="height: 26px; " class="tab_tr">
332 <td class="tab_td_right" style="width:80px;">
333 :
334 </td>
335 <td class="tab_td_left" colspan="3">
336 <div>
337 <asp:TextBox ID="FilePath" name="FilePath" runat="server" CssClass="txtInput normal left"
338 MaxLength="255"></asp:TextBox>
339 <a href="javascript:;" class="files">
340 <input type="file" id="FileUpload" name="FileUpload" onchange="Upload('SingleFile', 'FilePath', 'FileUpload');" /></a>
341 <span class="uploading"> , ...</span>
342 </div>
343 </td>
344 </tr>
345 <tr style="height: 26px;" class="tab_tr">
346 <td class="tab_td_right" style="width:80px;">
347 :
348 </td>
349 <td class="tab_td_left" colspan="3">
350 <textarea id="Describe" name="Describe" style="width: 99%; height: 100px; visibility: hidden;"
351 runat="server"></textarea>
352 </td>
353 </tr>
354 </table>
355 </form>
356 </div>
357 <div id="dlg-buttons">
358 <a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-ok" onclick="Save()">
359 </a> <a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-cancel"
360 onclick="javascript:$('#dlg').dialog('close')"> </a>
361 </div>
362 </body>
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
jQuery 전후 예이 기사에서는 jquery after() 및 before() 메소드의 예를 볼 것입니다. before() 메서드는 선택한 요소 앞에 지정된 콘텐츠를 삽입합니다. after() 메서드는 선택한 요소 뒤에 지정된 콘텐츠...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.