Selasa, 25 Agustus 2020

Query Select Left Join with sum

 a

select sia_kelas.*, sia_dagur.idx, sia_dagur.nama,lk,pr 
      from sia_kelas
      left join (select kelas,
      SUM(CASE WHEN kelamin='Laki-laki' THEN 1 ELSE 0 END) as lk,
      SUM(CASE WHEN kelamin='Perempuan' THEN 1 ELSE 0 END) as pr
      from sia_dasis where owner='$owner->owner' and kelas!='' group by kelas) dasis
      on sia_kelas.kelas=dasis.kelas
      LEFT JOIN sia_dagur 
      ON sia_dagur.idx=sia_kelas.wali
      where sia_kelas.owner='$owner->owner
      and sia_kelas.ta='$tahun'
      order by nmr ASC

b

Rabu, 12 Agustus 2020

VBA Excel Macro - Create List a to z

 a'''

Sub u()
ichr = Asc("a")
For i = 0 To 26
    Cells(i, 1) = Chr(ichr + i)

    '---------------------------------------------
    'USER ACTION
    ' Your letter is stored in the variable Letter.
    ' Do what you want with it here.
    ' For example: Range("A" & i) = Letter
    '---------------------------------------------

Next i
End Sub



v

Sabtu, 01 Agustus 2020

Radio Button Event Handler

var rad = document.myForm.myRadios;
var prev = null;
for (var i = 0; i < rad.length; i++) {
    rad[i].addEventListener('change', function() {
        (prev) ? console.log(prev.value): null;
        if (this !== prev) {
            prev = this;
        }
        console.log(this.value)
    });
}
<form name="myForm">
  <input type="radio" name="myRadios"  value="1" />
  <input type="radio" name="myRadios"  value="2" />
</form>

Rabu, 29 Juli 2020

Give All Form Input Same Class

Code at bottom page

//      var inputs=document.getElementById("fminput").getElementsByTagName("*");
      var inputs=document.getElementsByTagName("*");
      for (i = 0i < inputs.lengthi++) {
        try{
          if(inputs[i].type.toLowerCase() == 'text'  || inputs[i].tagName.toLowerCase() == 'textarea' || inputs[i].tagName.toLowerCase() == 'select') {
            inputs[i].className += " form-control input-sm";
          }
        }catch(e){}
      }

Sabtu, 25 Juli 2020

href confirmation

html
<a href="delete.php?id=22" onclick="return confirm('Are you sure?')">Link</a>
javascript
<script>
function hps(id){
  if (window.confirm('Yakin akan menghapus?'))
  {
    $.post("",{hps:id} ).done(function(response){
      var wnd = window.open("about:blank""""_blank");
      wnd.document.write(response);
      //var node = response.split("<<<");
      //if(node[1]==" ok "){location.reload(true);}
    });  
  }else{
      // They clicked no
  }
}
</script>


aa

html
<a href="delete.php?id=22" onclick="return confirm('Are you sure?')">Link</a>
javascript
<button onclick="if(confirm('Are you sure?')) saveandsubmit(event);"></button>


atau


<button onclick="return confirm('Are you sure?')?saveandsubmit(event):'';"></button>

Sabtu, 18 Juli 2020

Javascript Post Form

a
<script>
/**
 * sends a request to the specified url from a form. this will change the window location.
 * @param {string} path the path to send the post request to
 * @param {object} params the paramiters to add to the url
 * @param {string} [method=post] the method to use on the form
 */

function f_post(path, params, method='post') {

// The rest of this code assumes you are not using a library.
// It can be made less wordy if you use one.
const form = document.createElement('form');
form.method = method;
form.action = path;

for (const key in params) {
  if (params.hasOwnProperty(key)) {
    const hiddenField = document.createElement('input');
    hiddenField.type = 'hidden';
    hiddenField.name = key;
    hiddenField.value = params[key];

    form.appendChild(hiddenField);
  }
}

document.body.appendChild(form);
form.submit();
}
</script>
a

Kamis, 16 Juli 2020

Java Script Print Elemet / Print Div

a
//PRINT TO NEW WINDOW
function printDiv(elementId)
{
 var orig = document.getElementById(elementId);
 var printContent = orig.cloneNode(true);
 var inputs=printContent.getElementsByTagName("*");
  for (i = 0; i < inputs.length; i++) {
    if(inputs[i].type == 'text'){
      inputs[i].parentElement.innerHTML=inputs[i].value;
    }
  }
 var wnd = window.open("about:blank""""_blank");
 wnd.document.write('<head><title>Dointech Printer</title></head><link type="text/css" rel="stylesheet" href="cetak/print-styles.css">'+printContent.innerHTML);
 wnd.document.close();
 wnd.focus();
 wnd.print();
 //printWindow.print();
 //printWindow.close();
}
b