SHOW:
|
|
- or go back to the newest paste.
| 1 | $(document).on('click','.btn-ajax-xls',function(){
| |
| 2 | $('#dialog-body').html('<textarea id="xls" class="xlsx" name="xls" ><p>Copas Nilai Format Excel Anda di sini dengan urutan:<br>NISN | Nama | Skor 1 | Skor 2 | Skor 3 ... </p></textarea>');
| |
| 3 | $('#dialog-body').append('<a href="#" class="btn btn-default btn-ajax-xls-ok">Ok</a>');
| |
| 4 | CKEDITOR.config.removePlugins = list; | |
| 5 | CKEDITOR.config.height = 450; | |
| 6 | $( 'textarea' ).ckeditor(); | |
| 7 | }) | |
| 8 | ||
| 9 | $(document).on('click','.btn-ajax-xls-ok',function(){
| |
| 10 | var source=$(CKEDITOR.instances['xls'].getData()); | |
| 11 | var target=$('#content').html();
| |
| 12 | var row=[]; | |
| 13 | $.each( source, function( i, el ) {
| |
| 14 | if(el.nodeName=='TABLE'){
| |
| 15 | tbody = $(el).children('tbody');
| |
| 16 | tr = $(tbody).children(); | |
| 17 | $.each(tr,function(j,etr){
| |
| 18 | td=$(etr).children('td');
| |
| 19 | $.each(td,function(k,etd){
| |
| 20 | if(k==0){
| |
| 21 | index=$(etd).html(); | |
| 22 | row[index]=[]; | |
| 23 | l=0; | |
| 24 | } | |
| 25 | else{
| |
| 26 | if($(etd).html()*1>0 || $(etd).html()=='' || $(etd).html()==0){
| |
| 27 | row[index][l]=$(etd).html()*1; | |
| 28 | l++; | |
| 29 | } | |
| 30 | } | |
| 31 | }) | |
| 32 | }) | |
| 33 | } | |
| 34 | }); | |
| 35 | tr=$('#content').children('tr');
| |
| 36 | $.each(tr, function(i,v){
| |
| 37 | td=$(v).children('td');
| |
| 38 | $.each(td, function(j,w){
| |
| 39 | if(j==1){
| |
| 40 | index=$(w).html() | |
| 41 | k=0; | |
| 42 | } | |
| 43 | else if(j>2){
| |
| 44 | input = $(w).children('input');
| |
| 45 | if(typeof(row[index])!='undefined'){
| |
| 46 | if(typeof(row[index][k])!='undefined'){
| |
| 47 | $(input).val(row[index][k]) | |
| 48 | k++; | |
| 49 | } | |
| 50 | } | |
| 51 | } | |
| 52 | }) | |
| 53 | }) | |
| 54 | $('#myModal').modal('hide');
| |
| 55 | }) |