Ignore:
Timestamp:
10/13/13 09:40:26 (11 years ago)
Author:
tanio
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • schedule/function/SplitDelete.php

    r16984 r17218  
    1 
    21<script src="js/jquery-1.7.1.js"></script>
    32<script language="javascript">
    4 
    5 var timeval = 0;
    6 var name = "";
    7 var hid = "";
    8 var opt = "";
    9 window.cnt=0;
    103        function clearNode(node){
    114                var child = node.childNodes[0];
     
    1710        }
    1811       
    19        
    2012        function addRow(table){
    21             var targetView = table;
     13                var targetView = table;
    2214                // CREATE ELEMENT       
    2315                var newtr = document.createElement("tr");
    2416               
    2517                var newtd_c1 = document.createElement("td");
    26                         newtd_c1.setAttribute("width","115");
     18                        newtd_c1.setAttribute("width","147");
    2719                        newtd_c1.setAttribute("align","center");
    2820                        newtd_c1.appendChild(
     
    3123                                input_data.setAttribute("size","10"),
    3224                                input_data.setAttribute("autofocus","true"),
    33                                 input_data.setAttribute("hidden",true)
     25                                input_data.setAttribute("hidden","true")
    3426                        );
    3527                var newtd_c2 = document.createElement("td");
    36                         newtd_c2.setAttribute("width","40");
     28                        newtd_c2.setAttribute("width","138");
    3729                        newtd_c2.setAttribute("align","center");
    3830                        newtd_c2.appendChild(
    39                                 selection = document.createElement("select"),
     31                       
     32
     33
     34                        selection = document.createElement("select"),
    4035                                <?php   
    4136                                $selectm = mysql_query("SELECT * FROM measurement");
     
    4843                        );
    4944                       
    50                         //var newtd_c2 = document.createElement("td");
     45                       
     46                       
     47                       
     48                       
    5149                        newtd_c2.setAttribute("width","115");
    5250                        newtd_c2.setAttribute("align","center");
     
    5452                                input_data = document.createElement("input"),
    5553                                input_data.setAttribute("type","button"),
    56                                 input_data.setAttribute("value","[ + ]"),
     54                                input_data.setAttribute("id","plus"),
     55                                input_data.setAttribute("value","+"),
    5756                                input_data.onclick = function(){ return addRow(newtr); }
    5857                        );
    59                
    6058                var newtd_c3 = document.createElement("td");
    61                         newtd_c3.setAttribute("width","88");
     59                        newtd_c3.setAttribute("width","98");
    6260                        newtd_c3.setAttribute("align","center");
    6361                        newtd_c3.appendChild(
     
    7472                        selection.setAttribute('id','measurement')
    7573                        );
     74                       
     75                       
     76                       
    7677                var newtd_c4 = document.createElement("td");
    77                         newtd_c4.setAttribute("width","180");
     78                        newtd_c4.setAttribute("width","119");
    7879                        newtd_c4.setAttribute("align","center");
    7980                        newtd_c4.appendChild(
    8081                                input_data = document.createElement("input"),
    8182                                input_data.setAttribute("type","text"),
    82                                 input_data.setAttribute("size","25"),
     83                                input_data.setAttribute("size","12"),
    8384                                input_data.setAttribute("placeholder","Value")
    8485                        );
    8586                var newtd_c5 = document.createElement("td");
    86                         newtd_c5.setAttribute("width","95");
     87                        newtd_c5.setAttribute("width","115");
    8788                        newtd_c5.setAttribute("align","center");
    8889                        newtd_c5.appendChild(
    8990                                input_data = document.createElement("input"),
    9091                                input_data.setAttribute("type","button"),
    91                                 input_data.setAttribute("value","[ Delete ]"),
     92                                input_data.setAttribute("id","delete"),
     93                                input_data.setAttribute("value","Delete"),
    9294                                input_data.onclick = function(){ return clearNode(newtr); }
    9395                        );
    9496               
    95                 newtr.appendChild(newtd_c1);
    9697                newtr.appendChild(newtd_c2);
    9798                newtr.appendChild(newtd_c3);
    9899                newtr.appendChild(newtd_c4);
    99100                newtr.appendChild(newtd_c5);
    100         //newtr.appendChild(newtd_c6);
    101101               
    102102                $(targetView).after(newtr);
    103        
    104103        }
    105        
    106104        function deleteRow(tableID){
    107105                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){
    116114                                                alert("Cannot delete all the rows.");
    117115                                                break;
    118116                                        }
    119117                                        table.deleteRow(i);
    120                                         rowCount--;i--;
     118                                        rowCount--; i--;
    121119                                }
    122120                        }
     
    137135                newdiv.setAttribute("id","list_"+newlist);
    138136                newdiv.setAttribute("class","datalisting");
    139                 newdiv.setAttribute("style","margin:5px 0;");
     137                newdiv.setAttribute("style","margin:30px 0;");
    140138        var newtable = document.createElement("table");
    141139                newtable.setAttribute("class","dataTable");
    142                 newtable.setAttribute("width","100%");
    143                 newtable.setAttribute("border","3");
     140                newtable.setAttribute("width","900");
     141                newtable.setAttribute("border","1");
    144142                newtable.setAttribute("cellspacing","0");
    145143                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");
    146150               
    147151        var newtr = document.createElement("tr");
    148152       
    149153        var newtd_c1 = document.createElement("td");
    150                 newtd_c1.setAttribute("width","115");
     154                newtd_c1.setAttribute("width","160");
    151155                newtd_c1.setAttribute("align","center");
     156                newtd_c1.setAttribute("valign","top");
    152157                newtd_c1.appendChild(
    153158                        input_data = document.createElement("input"),
     
    159164                        input_data = document.createElement("input"),
    160165                        input_data.setAttribute("type","button"),
    161                         input_data.setAttribute("value","[ + ]"),
     166                        input_data.setAttribute("id","delete"),
     167                        input_data.setAttribute("value","+"),
    162168                        input_data.onclick = function(){
    163169                                addRowClone("list_"+newlist);
     
    165171                );
    166172        var newtd_c2 = document.createElement("td");
    167                 newtd_c2.setAttribute("width","40");
     173                newtd_c2.setAttribute("width","118");
    168174                newtd_c2.setAttribute("align","center");
    169175                newtd_c2.appendChild(
     
    181187                        );
    182188                       
    183 //              var newtd_c6 = document.createElement("td");
     189                       
     190                       
    184191                newtd_c2.setAttribute("width","115");
    185192                newtd_c2.setAttribute("align","center");
     
    187194                        input_data = document.createElement("input"),
    188195                        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(
    196205                                selection = document.createElement("select"),
    197206                <?php
     
    207216                        selection.setAttribute('id','measurement')
    208217                );
    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                );
    229243        newtr.appendChild(newtd_c2);
    230244        newtr.appendChild(newtd_c3);
    231245        newtr.appendChild(newtd_c4);
    232246        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
    236275        newdiv.appendChild(newtable);
    237        
    238276        if(nextrow != null){   
    239277                var doc = document.getElementById(nextrow);
     
    243281        }
    244282}
     283
    245284window.onload = function(){
    246285        addRowClone();
     
    249288</script>
    250289
     290
     291
     292
     293<style>
     294#delete{
     295        cursor: pointer;
     296border-top: 1px solid #96d1f8;
     297background: #65a9d7;
     298background: -webkit-gradient(linear, left top, left bottom, from(#3e779d), to(#65a9d7));
     299background: -webkit-linear-gradient(top, #3e779d, #65a9d7);
     300background: -moz-linear-gradient(top, #3e779d, #65a9d7);
     301background: -ms-linear-gradient(top, #3e779d, #65a9d7);
     302background: -o-linear-gradient(top, #3e779d, #65a9d7);
     303padding: 3px 6px;
     304-webkit-border-radius: 6px;
     305-moz-border-radius: 6px;
     306border-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;
     309box-shadow: rgba(0,0,0,1) 0 1px 0;
     310text-shadow: rgba(0,0,0,.4) 0 1px 0;
     311color: white;
     312font-size: 14px;
     313font-family: 'Lucida Grande', Helvetica, Arial, Sans-Serif;
     314text-decoration: none;
     315vertical-align: middle;
     316}
     317#plus{
     318        cursor: pointer;
     319border-top: 1px solid #96d1f8;
     320background: #65a9d7;
     321background: -webkit-gradient(linear, left top, left bottom, from(#3e779d), to(#65a9d7));
     322background: -webkit-linear-gradient(top, #3e779d, #65a9d7);
     323background: -moz-linear-gradient(top, #3e779d, #65a9d7);
     324background: -ms-linear-gradient(top, #3e779d, #65a9d7);
     325background: -o-linear-gradient(top, #3e779d, #65a9d7);
     326padding: 3px 6px;
     327-webkit-border-radius: 6px;
     328-moz-border-radius: 6px;
     329border-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;
     332box-shadow: rgba(0,0,0,1) 0 1px 0;
     333text-shadow: rgba(0,0,0,.4) 0 1px 0;
     334color: white;
     335font-size: 14px;
     336font-family: 'Lucida Grande', Helvetica, Arial, Sans-Serif;
     337text-decoration: none;
     338vertical-align: middle;
     339}
     340</style>
    251341
    252342</head>
Note: See TracChangeset for help on using the changeset viewer.