Senin, 21 Desember 2020

ajax fill from json

 contoh 1


	function loadbrg(id,vnd){
		document.forms['fmedit'].querySelectorAll('input[name^="a"]').forEach(function(el){el.value='';});
		$("#modaledit").modal();
		//if(id==0)document.forms['fmtarget'].querySelectorAll('input[name^="a"]').forEach(function(el){el.value=el.name;});
		if(id==0)return;
		var oTXT=document.forms['fmedit'].querySelectorAll('input[name^="a"]');
		$.post("?act=loadbrg&id="+id+"&vnd="+vnd).done(function(response){
			console.log(response);
			$.each(oTXT, function( key, value ) {
				var otxt=value.name.replace('a[','').replace(']','');
				value.value=response[otxt];
				//console.log(key+"="+value.value+"->"+otxt);
			});
		});
	}


contoh 2


	var fmtarget=document.forms['fmpopup'];
	fmtarget.querySelectorAll('input').forEach(function(el){el.value='';});
	$.post("?act=loadlembar",{idobj:idobj}).done(function(response){
		console.log(response);
		$.each(response, function( key, value ) {
			try {
				fmtarget["a["+key+"]"].value=value;
			}
			catch(err) {console.log("a["+key+"]"+err.message);}
		});
	});

Selasa, 10 November 2020

Popup Submit

document.getElementById("btnsumbit").addEventListener("click",function(){
	$('#popup').modal('hide');
	$.post("?act=save",$(this.form).serialize()).done(function(response){
		console.log(response);
		if(response.split("<<<")[1]==" reload ")location.reload(true);
	});
	event.preventDefault();
});
          
fmtarget.querySelectorAll('input[type=text]').forEach(function(el){
	console.log(el.name);
	el.value='';
});

Rabu, 04 November 2020

Falidate Form

 function validateForm() {

var ct=0;

var inputs=document.getElementsByTagName("input");

for (i = 0; i < inputs.length; i++) {

try{

if(inputs[i].value == '' && inputs[i].title.toLowerCase() == 'penting') {

ct = 1;

inputs[i].style.background= "blue";

}

}catch(e){}

}

    if (ct != 0) {

        alert("Yang Berwarna kuning harus di isi");

        return false;

    }

}










x = document.querySelectorAll(".example");

  for (i = 0; i < x.length; i++) {

    x[i].style.backgroundColor = "red";

  }

Selasa, 03 November 2020

HTML Basic

 HTML Check Checked


dd

Rabu, 07 Oktober 2020

Upload file using VB.NET and PHP

VB COde

 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Using wc As New System.Net.WebClient()

            wc.UploadFile("http://apps.pastioke.com/info.php", "x:\wa.php")

        End Using

    End Sub



PHP CODE

<?

if($_FILES){

$myfile = fopen("newfile.txt", "w") or die("Unable to open file!");

$txt = print_r($_FILES, true);

$target_file = 'ff.txt';

move_uploaded_file($_FILES["file"]["tmp_name"], $target_file);

fwrite($myfile, $txt);

$txt = print_r($_GET);

fwrite($myfile, $txt);

fclose($myfile);

?>


s

Minggu, 04 Oktober 2020

Rabu, 30 September 2020

Javascript event listener on all class

  const divs = document.querySelectorAll('.hitung');

or

 const divs = document.querySelector('button[type="submit"]');

divs.forEach(el => el.addEventListener('keyup', event => {

var fm=el.form;

fm['a[harga1]'].value=fm["a[bruto]"].value - (fm["a[diskon1]"].value * fm["a[bruto]"].value / 100);

fm['a[harga2]'].value=fm["a[harga1]"].value - (fm["a[diskon2]"].value * fm["a[harga1]"].value / 100);

fm['a[harga3]'].value=fm["a[harga2]"].value - (fm["a[diskon3]"].value * fm["a[harga2]"].value / 100);

fm['a[harga]'].value=fm['a[harga3]'].value;


event.preventDefault();

  //console.log(event.target.classList[1]);

}));


Minggu, 27 September 2020

Ajax JSON to fill form

form to display data

 code to load data

code to display

Minggu, 13 September 2020

PHP Menghitung sisa waktu mengerjakan CBT

 $mulai=explode(":",$logtugas->jammulai)[0]*3600 + explode(":",$logtugas->jammulai)[1]*60 + explode(":",$logtugas->jammulai)[2]*1;

$sekarang=date("H")*3600 + date("i")*60 + date("s")*1;

$akhir=$mulai*1 + ($logtugas->durasi*60) ;

$sisawaktu=$akhir*1 - $sekarang*1;

Senin, 07 September 2020

Let's encrypt Wilcard ssl on Centos 7

yum install epel-release
yum install yum-utils
yum install python2-certbot-apache
yum install python2-certbot-nginx


certbot certonly --manual -d *.easyware.id -d easyware.id --agree-tos --manual-public-ip-logging-ok --preferred-challenges dns-01 --server https://acme-v02.api.letsencrypt.org/directory

certbot certonly --manual -d *.pastioke.com --agree-tos --manual-public-ip-logging-ok --preferred-challenges dns-01 --server https://acme-v02.api.letsencrypt.org/directory --register-unsafely-without-email


key
/etc/letsencrypt/live/easyware.id/privkey.pem


cert atas //  CA bundle bawah
/etc/letsencrypt/live/easyware.id/fullchain.pem


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

Minggu, 05 Juli 2020

Javascript Jquery Prevent Form Submit

PHP CODE


javascript
  <script>
  var inputs=document.getElementsByTagName("*");
  for (i = 0i < inputs.lengthi++) {
    try{
      if(inputs[i].name.includes("a[")){
        inputs[i].value = "sss"+inputs[i].name.replace("a[""[a|");
      }
      if(inputs[i].type=='submit'){
        inputs[i].addEventListener("click"function(event){
          $.post("?input&act=save",$(this.form).serialize()).done(function(response){
console.log(response);
            //var node = response.split("<<<");
            //if(node[1]==" ok "){location.reload(true);}
            var wnd = window.open("about:blank""""_blank");
            //wnd.document.write(node[1]);
            wnd.document.write(response);
          });  
        event.preventDefault();
        });
      }
    }catch(e){}
  }
  </script>
d
<script>
      function addsiswa(id){
        $.post("",{id:id} ).done(function(response){
            var node = response.split("<<<");
            if(node[1]==" ok "){location.reload(true);}
            //var wnd = window.open("about:blank", "", "_blank");
            //wnd.document.write(node[1]);
            //wnd.document.write(response);
          });  
      }
</script>
d
d

Sabtu, 04 Juli 2020

PHP: Show and List all Column name of an msyql table

Code
<? $conn = new stdClass; $conn->user='root'; $conn->pwd=''; $conn->db = 'abnetid_apps2';//.explode(".",$_SERVER["HTTP_HOST"])[0]; $conn->host ='localhost'; $conn->tb = 'des_daduk'; $dbservertype = 'mysqli'; $table_pref = 'finance'; $upload_dir = "../uploads/"; // connect MYSQLI database dengan user root $db = mysqli_connect($conn->host, $conn->user, $conn->pwd,$conn->db); if (!$db)die('Could not connect: ' . mysqli_error($mydb)); ?> <textarea style="width:100%; height:40vh"> <? $colname=$db->query("SELECT COLUMN_NAME as nama FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '$conn->db' AND TABLE_NAME = '$conn->tb';"); while ($rw = mysqli_fetch_object($colname)) { echo "$rw->nama: <input name='a[$rw->nama]' value='".'<? echo $rw->'.$rw->nama."?>' type='text' class='form-control' />\r\n"; } ?> <button type="submit" id="oprevent" name='act' value='save' class="btn btn-success">Siman</button> </textarea>

<textarea style="width:100%; height:10vh"> <? $colname=$db->query("SELECT COLUMN_NAME as nama FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '$conn->db' AND TABLE_NAME = '$conn->tb';"); while ($rw = mysqli_fetch_object($colname)) { echo "$rw->nama\t"; } ?> </textarea>

or

<textarea style="width:100%">
<table>
<?
$colname=$db->query("SELECT COLUMN_NAME as nama FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = 'admin_nu' AND TABLE_NAME = 'nu_keuangan';");
while ($rw = mysqli_fetch_object($colname)) {
  echo "<tr><td>$rw->nama: </td><td><input name='a[$rw->nama]' value='".'<? echo $rw->'.$rw->nama."?>' type='text' class='form-control' /></td></tr>\r\n";
}
?>
</table>
<button type='submit' id='oprevent' class='btn btn-primary'>Simpan</button>
</textarea>

PHP Code
<?
if($_GET[act]=="save"){
  $aa=(object$_POST[a];
  foreach($aa as $key => $value) {$s .= "$key='".mysqli_real_escape_string($db,$value)."', ";}
  $s=rtrim($s", ");
  $s="insert INTO sia_owner set $s ON DUPLICATE KEY UPDATE $s";
  $db->query($s);
  echo " | $s |";
  echo "<<< ok <<<";
  exit;
}
?>
z
<script>
document.getElementById("oprevent").addEventListener("click"function(event){
  $.post("?txt&act=save",$(this.form).serialize()).done(function(response){
    //var wnd = window.open("about:blank", "", "_blank");
    //wnd.document.write(response);
    var node = response.split("<<<");
    if(node[1]==" ok "){alert('data telah tersimpan');location.reload(true);}
  });  
  event.preventDefault();
});
</script>


zz
function hps(id){
  if (window.confirm('Yakin akan menghapus?'))
  {
    $.post("",{hps:id} ).done(function(response){
     var node = response.split("<<<");
      if(node[1]==" ok "){location.reload(true);}
      //var wnd = window.open("about:blank", "", "_blank");
      //wnd.document.write(response);
    });  
  }else{
      // They clicked no
  }
}

Fill Form Field Object with Own Name

s
  <script>
  var inputs=document.getElementsByTagName("*");
  for (i = 0; i < inputs.length; i++) {
    try{
      if(inputs[i].type.toLowerCase() == 'text'  || inputs[i].tagName.toLowerCase() == 'textarea' || inputs[i].tagName.toLowerCase() == 'select') {
        inputs[i].value = inputs[i].name.replace("a[", "[a|");
        inputs[i].name = inputs[i].name.replace("a[", "[a|");
      }
    }catch(e){}
  }

  </script>
s

<script>
  var inputs=document.getElementsByTagName("*");
  for (i = 0; i < inputs.length; i++) {
    try{
      if(inputs[i].name.includes("a[")){
        inputs[i].value = inputs[i].name.replace("a[""[a|");
      }
    }catch(e){}
  }

  </script>

s

Minggu, 28 Juni 2020

Styling Table


.xfit{  width:1%;   white-space:nowrap;}

Dropdown Menu Hover

STYLE
<style>
.dropbtn {
    background-color: #4CAF50;
    color: white;
    border: none;
}

.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-content {
    display: none;
    position: absolute;
    background-color:#009900;
    min-width160px;
    box-shadow0px 8px 16px 0px rgba(0,0,0,0.2);
    z-index1;
}

.dropdown-content a {
    color:white;
    padding2px 16px;
    text-decoration: none;
    display: block;
}
.dropdown:hover .dropdown-content {display: block;}
.dropdown-content a:hover {background-color:#006633;}
.dropdown:hover .dropbtn {background-color:#006633;}

/*
.dropdown-content a:hover {background-color: #ddd;}
.dropdown:hover .dropbtn {background-color: #3e8e41;}
*/
</style>


HTML
<div class="dropdown" style="width:100%;"><? echo $rows->c ?>
                    <div id="myDropdown" class="dropdown-content" style="margin-left:5px; width:100%; float:right ">
                    <a href="?ajax=index&pass=<? echo $rows->b?>"><i class="glyphicon-paperclip glyphicon"></i> Layanan</a>
                    <a href="?d=<? echo $rows->d?>"><i class="fa fa-sitemap"></i> Lihat Anggota KK</a> 
                    <a href="?b=<? echo $rows->b?>"><i class="fa fa-edit"></i> Edit</a> 
                    <a href="?b=new&d=<? echo $rows->d?>"><i class="fa fa-plus"></i> Tambah Anggota</a> 
                    <a href="?d=<? echo $rows->d?>&k=<? echo $rows->idx?>"  onclick="return confirm('Yakin akan menghapus <? echo $rows->c ?> ?')"><i class="fa fa-trash-o"></i> Hapus</a> 
                    </div>
                    </div>





Foto Propades