Changeset 17218 for schedule/function
- Timestamp:
- 10/13/13 09:40:26 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
schedule/function/SplitDelete.php
r16984 r17218 1 2 1 <script src="js/jquery-1.7.1.js"></script> 3 2 <script language="javascript"> 4 5 var timeval = 0;6 var name = "";7 var hid = "";8 var opt = "";9 window.cnt=0;10 3 function clearNode(node){ 11 4 var child = node.childNodes[0]; … … 17 10 } 18 11 19 20 12 function addRow(table){ 21 13 var targetView = table; 22 14 // CREATE ELEMENT 23 15 var newtr = document.createElement("tr"); 24 16 25 17 var newtd_c1 = document.createElement("td"); 26 newtd_c1.setAttribute("width","1 15");18 newtd_c1.setAttribute("width","147"); 27 19 newtd_c1.setAttribute("align","center"); 28 20 newtd_c1.appendChild( … … 31 23 input_data.setAttribute("size","10"), 32 24 input_data.setAttribute("autofocus","true"), 33 input_data.setAttribute("hidden", true)25 input_data.setAttribute("hidden","true") 34 26 ); 35 27 var newtd_c2 = document.createElement("td"); 36 newtd_c2.setAttribute("width"," 40");28 newtd_c2.setAttribute("width","138"); 37 29 newtd_c2.setAttribute("align","center"); 38 30 newtd_c2.appendChild( 39 selection = document.createElement("select"), 31 32 33 34 selection = document.createElement("select"), 40 35 <?php 41 36 $selectm = mysql_query("SELECT * FROM measurement"); … … 48 43 ); 49 44 50 //var newtd_c2 = document.createElement("td"); 45 46 47 48 51 49 newtd_c2.setAttribute("width","115"); 52 50 newtd_c2.setAttribute("align","center"); … … 54 52 input_data = document.createElement("input"), 55 53 input_data.setAttribute("type","button"), 56 input_data.setAttribute("value","[ + ]"), 54 input_data.setAttribute("id","plus"), 55 input_data.setAttribute("value","+"), 57 56 input_data.onclick = function(){ return addRow(newtr); } 58 57 ); 59 60 58 var newtd_c3 = document.createElement("td"); 61 newtd_c3.setAttribute("width"," 88");59 newtd_c3.setAttribute("width","98"); 62 60 newtd_c3.setAttribute("align","center"); 63 61 newtd_c3.appendChild( … … 74 72 selection.setAttribute('id','measurement') 75 73 ); 74 75 76 76 77 var newtd_c4 = document.createElement("td"); 77 newtd_c4.setAttribute("width","1 80");78 newtd_c4.setAttribute("width","119"); 78 79 newtd_c4.setAttribute("align","center"); 79 80 newtd_c4.appendChild( 80 81 input_data = document.createElement("input"), 81 82 input_data.setAttribute("type","text"), 82 input_data.setAttribute("size"," 25"),83 input_data.setAttribute("size","12"), 83 84 input_data.setAttribute("placeholder","Value") 84 85 ); 85 86 var newtd_c5 = document.createElement("td"); 86 newtd_c5.setAttribute("width"," 95");87 newtd_c5.setAttribute("width","115"); 87 88 newtd_c5.setAttribute("align","center"); 88 89 newtd_c5.appendChild( 89 90 input_data = document.createElement("input"), 90 91 input_data.setAttribute("type","button"), 91 input_data.setAttribute("value","[ Delete ]"), 92 input_data.setAttribute("id","delete"), 93 input_data.setAttribute("value","Delete"), 92 94 input_data.onclick = function(){ return clearNode(newtr); } 93 95 ); 94 96 95 newtr.appendChild(newtd_c1);96 97 newtr.appendChild(newtd_c2); 97 98 newtr.appendChild(newtd_c3); 98 99 newtr.appendChild(newtd_c4); 99 100 newtr.appendChild(newtd_c5); 100 //newtr.appendChild(newtd_c6);101 101 102 102 $(targetView).after(newtr); 103 104 103 } 105 106 104 function deleteRow(tableID){ 107 105 try{ 108 var table =document.getElementById(tableID);109 var rowCount =table.rows.length;110 111 for(var i =0;i<rowCount;i++){112 var row =table.rows[i];113 var chkbox =row.cells[0].childNodes[0];114 if(null !=chkbox&&true==chkbox.checked){115 if(rowCount <=1){106 var table = document.getElementById(tableID); 107 var rowCount = table.rows.length; 108 109 for(var i = 0; i < rowCount; i++){ 110 var row = table.rows[i]; 111 var chkbox = row.cells[0].childNodes[0]; 112 if(null != chkbox && true == chkbox.checked){ 113 if(rowCount <= 1){ 116 114 alert("Cannot delete all the rows."); 117 115 break; 118 116 } 119 117 table.deleteRow(i); 120 rowCount--; i--;118 rowCount--; i--; 121 119 } 122 120 } … … 137 135 newdiv.setAttribute("id","list_"+newlist); 138 136 newdiv.setAttribute("class","datalisting"); 139 newdiv.setAttribute("style","margin: 5px 0;");137 newdiv.setAttribute("style","margin:30px 0;"); 140 138 var newtable = document.createElement("table"); 141 139 newtable.setAttribute("class","dataTable"); 142 newtable.setAttribute("width"," 100%");143 newtable.setAttribute("border"," 3");140 newtable.setAttribute("width","900"); 141 newtable.setAttribute("border","1"); 144 142 newtable.setAttribute("cellspacing","0"); 145 143 newtable.setAttribute("cellpadding","0"); 144 var newInnertable = document.createElement("table"); 145 newInnertable.setAttribute("class","dataTable"); 146 newInnertable.setAttribute("width","600"); 147 newInnertable.setAttribute("border","1"); 148 newInnertable.setAttribute("cellspacing","0"); 149 newInnertable.setAttribute("cellpadding","0"); 146 150 147 151 var newtr = document.createElement("tr"); 148 152 149 153 var newtd_c1 = document.createElement("td"); 150 newtd_c1.setAttribute("width","1 15");154 newtd_c1.setAttribute("width","160"); 151 155 newtd_c1.setAttribute("align","center"); 156 newtd_c1.setAttribute("valign","top"); 152 157 newtd_c1.appendChild( 153 158 input_data = document.createElement("input"), … … 159 164 input_data = document.createElement("input"), 160 165 input_data.setAttribute("type","button"), 161 input_data.setAttribute("value","[ + ]"), 166 input_data.setAttribute("id","delete"), 167 input_data.setAttribute("value","+"), 162 168 input_data.onclick = function(){ 163 169 addRowClone("list_"+newlist); … … 165 171 ); 166 172 var newtd_c2 = document.createElement("td"); 167 newtd_c2.setAttribute("width"," 40");173 newtd_c2.setAttribute("width","118"); 168 174 newtd_c2.setAttribute("align","center"); 169 175 newtd_c2.appendChild( … … 181 187 ); 182 188 183 // var newtd_c6 = document.createElement("td"); 189 190 184 191 newtd_c2.setAttribute("width","115"); 185 192 newtd_c2.setAttribute("align","center"); … … 187 194 input_data = document.createElement("input"), 188 195 input_data.setAttribute("type","button"), 189 input_data.setAttribute("value","[ + ]"), 190 input_data.onclick = function(){ return addRow(newtr); } 191 ); 192 var newtd_c3 = document.createElement("td"); 193 newtd_c3.setAttribute("width","98"); 194 newtd_c3.setAttribute("align","center"); 195 newtd_c3.appendChild( 196 input_data.setAttribute("id","plus"), 197 input_data.setAttribute("value","+"), 198 input_data.onclick = function(){ 199 return addRow(newtr); 200 }); 201 var newtd_c3 = document.createElement("td"); 202 newtd_c3.setAttribute("width","98"); 203 newtd_c3.setAttribute("align","center"); 204 newtd_c3.appendChild( 196 205 selection = document.createElement("select"), 197 206 <?php … … 207 216 selection.setAttribute('id','measurement') 208 217 ); 209 var newtd_c4 = document.createElement("td"); 210 newtd_c4.setAttribute("width","180"); 211 newtd_c4.setAttribute("align","center"); 212 newtd_c4.appendChild( 213 input_data = document.createElement("input"), 214 input_data.setAttribute("type","text"), 215 input_data.setAttribute("size","25"), 216 input_data.setAttribute("placeholder","Value") 217 ); 218 var newtd_c5 = document.createElement("td"); 219 newtd_c5.setAttribute("width","95"); 220 newtd_c5.setAttribute("align","center"); 221 newtd_c5.appendChild( 222 input_data = document.createElement("input"), 223 input_data.setAttribute("type","button"), 224 input_data.setAttribute("value","[ Delete Main ]"), 225 input_data.onclick = function(){ return clearNode(newdiv); } 226 ); 227 228 newtr.appendChild(newtd_c1); 218 219 220 221 var newtd_c4 = document.createElement("td"); 222 newtd_c4.setAttribute("width","119"); 223 newtd_c4.setAttribute("align","center"); 224 newtd_c4.appendChild( 225 input_data = document.createElement("input"), 226 input_data.setAttribute("type","text"), 227 input_data.setAttribute("size","12"), 228 input_data.setAttribute("placeholder","Value") 229 ); 230 var newtd_c5 = document.createElement("td"); 231 newtd_c5.setAttribute("width","100"); 232 newtd_c5.setAttribute("align","center"); 233 newtd_c5.setAttribute("width","115"); 234 newtd_c5.setAttribute("align","center"); 235 newtd_c5.appendChild( 236 input_data = document.createElement("input"), 237 input_data.setAttribute("type","button"), 238 input_data.setAttribute("id","delete"), 239 input_data.setAttribute("value","Delete"), 240 input_data.onclick = function(){ return clearNode(newtr); 241 } 242 ); 229 243 newtr.appendChild(newtd_c2); 230 244 newtr.appendChild(newtd_c3); 231 245 newtr.appendChild(newtd_c4); 232 246 newtr.appendChild(newtd_c5); 233 //newtr.appendChild(newtd_c6); 234 235 newtable.appendChild(newtr); 247 248 newInnertable.appendChild(newtr); 249 var newtd_c6 = document.createElement("td"); 250 newtd_c6.appendChild(newInnertable); 251 252 var newtd_c7 = document.createElement("td"); 253 newtd_c7.setAttribute("width","115"); 254 newtd_c7.setAttribute("align","center"); 255 newtd_c7.setAttribute("valign","top"); 256 newtd_c7.appendChild( 257 input_data = document.createElement("input"), 258 input_data.setAttribute("type","button"), 259 input_data.setAttribute("height","30"), 260 input_data.setAttribute("id","delete"), 261 input_data.setAttribute("value","Delete Main"), 262 input_data.onclick = function(){ return clearNode(newdiv); } 263 ); 264 265 var newOutertr = document.createElement("tr"); 266 267 //newOutertr.appendChild(newtd_c1); 268 //newOutertr.appendChild(newtd_c6); 269 //newOutertr.appendChild(newtd_c7); 270 271 newtable.appendChild(newtd_c1); 272 newtable.appendChild(newtd_c6); 273 newtable.appendChild(newtd_c7); 274 236 275 newdiv.appendChild(newtable); 237 238 276 if(nextrow != null){ 239 277 var doc = document.getElementById(nextrow); … … 243 281 } 244 282 } 283 245 284 window.onload = function(){ 246 285 addRowClone(); … … 249 288 </script> 250 289 290 291 292 293 <style> 294 #delete{ 295 cursor: pointer; 296 border-top: 1px solid #96d1f8; 297 background: #65a9d7; 298 background: -webkit-gradient(linear, left top, left bottom, from(#3e779d), to(#65a9d7)); 299 background: -webkit-linear-gradient(top, #3e779d, #65a9d7); 300 background: -moz-linear-gradient(top, #3e779d, #65a9d7); 301 background: -ms-linear-gradient(top, #3e779d, #65a9d7); 302 background: -o-linear-gradient(top, #3e779d, #65a9d7); 303 padding: 3px 6px; 304 -webkit-border-radius: 6px; 305 -moz-border-radius: 6px; 306 border-radius: 6px; 307 -webkit-box-shadow: rgba(0,0,0,1) 0 1px 0; 308 -moz-box-shadow: rgba(0,0,0,1) 0 1px 0; 309 box-shadow: rgba(0,0,0,1) 0 1px 0; 310 text-shadow: rgba(0,0,0,.4) 0 1px 0; 311 color: white; 312 font-size: 14px; 313 font-family: 'Lucida Grande', Helvetica, Arial, Sans-Serif; 314 text-decoration: none; 315 vertical-align: middle; 316 } 317 #plus{ 318 cursor: pointer; 319 border-top: 1px solid #96d1f8; 320 background: #65a9d7; 321 background: -webkit-gradient(linear, left top, left bottom, from(#3e779d), to(#65a9d7)); 322 background: -webkit-linear-gradient(top, #3e779d, #65a9d7); 323 background: -moz-linear-gradient(top, #3e779d, #65a9d7); 324 background: -ms-linear-gradient(top, #3e779d, #65a9d7); 325 background: -o-linear-gradient(top, #3e779d, #65a9d7); 326 padding: 3px 6px; 327 -webkit-border-radius: 6px; 328 -moz-border-radius: 6px; 329 border-radius: 6px; 330 -webkit-box-shadow: rgba(0,0,0,1) 0 1px 0; 331 -moz-box-shadow: rgba(0,0,0,1) 0 1px 0; 332 box-shadow: rgba(0,0,0,1) 0 1px 0; 333 text-shadow: rgba(0,0,0,.4) 0 1px 0; 334 color: white; 335 font-size: 14px; 336 font-family: 'Lucida Grande', Helvetica, Arial, Sans-Serif; 337 text-decoration: none; 338 vertical-align: middle; 339 } 340 </style> 251 341 252 342 </head>
Note:
See TracChangeset
for help on using the changeset viewer.