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='';
});
Selasa, 10 November 2020
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";
}
Minggu, 04 Oktober 2020
Little Javascript Trick
Move Document to End (Scroll to end)
window.scrollTo(0,document.body.scrollHeight);
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]);
}));
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>Sabtu, 25 Juli 2020
href confirmation
<a href="delete.php?id=22" onclick="return confirm('Are you sure?')">Link</a><a href="delete.php?id=22" onclick="return confirm('Are you sure?')">Link</a><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
Minggu, 05 Juli 2020
Javascript Jquery Prevent Form Submit
javascript
Sabtu, 04 Juli 2020
Fill Form Field Object with Own Name
Rabu, 26 Februari 2020
Javascript JSON and ParseJson
echo '{"srt":"'.$rw->idx.'","nosur" : "'.$rw->nosur.'","kode": "'.$rw->kode.'", "cetak" : "'.$rw->cetak.'", "url" : "'.$rw->url.'"}';
Parse It
$.get("?ajax=../cetak/print2&cetak=" + srt,function(response){
if(response!=""){
var json=$.parseJSON(response);
$('#printmodal').modal();
fmcetak=document.forms['fmcetak'];
fmcetak.action='.?ajax='+loader+'&srt='+srt+'&src='+src;
fmcetak['nosur'].value=json['nosur'];
fmcetak.submit();
}
});
Kamis, 26 Desember 2019
javascript confirm href or confirm submit form
<td class="xfit">
<a href="?x=1" onclick="return confirm('Yakin akan menghapus <? echo $rw->nama_barang ?> ?')"?>
<? echo $i?>
</a>
</td>
Javascipt and jQuery addEventListener
<script>
document.getElementById("myBtn").addEventListener("click", displayDate);
function displayDate() {
document.getElementById("demo").innerHTML = Date();
}
</script>
-----------------------------------------------------------------------
if using jquery
-----------------------------------------------------------------------
Selasa, 08 Agustus 2017
Form Action Popup Windows
$qs=$_SERVER['QUERY_STRING'];
if($q!=""){
echo "<iframe src='https://script.google.com/macros/s/AKfycbwmZcgYrEN4vVuBVXGyRRfsSZ231PlnKl09A4Rv8sjaf1K3tWAM/exec?".."' width='100%' height='1300' frameborder='0' marginwidth='0' marginheight='0'>Memuat...</iframe>";
}else{
echo "<form action='https://script.google.com/macros/s/AKfycbxTbLgqvRSD_B7IDOLCybhk8tqRJFVGxcwWmiPcKBG6RcHjD1o/exec' method='get'>Silahkan masukkan kode file yang telah anda dapatkan dari email kami kemudian click tombol download";
$q=$qs;
if($q[0]=="")$q[0]="desa";
echo "<input name='$q[0]' class='form-control' type='text' placeholder='kode_file' value='$q[1]'/>";
}
[/insert_php]
<input type="submit" value="Download" class="btn btn-success" id="submiter" />
</form>
<script language="javascript">
var myForm = document.getElementById('formID');
myForm.onsubmit = function() {
var w = window.open('about:blank','Popup_Window','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=400,height=300,left = 312,top = 234');
this.target = 'Popup_Window';
};
function getQueryStringValue (key) {
return decodeURIComponent(window.location.search.replace(new RegExp("^(?:.*[&\\?]" + encodeURIComponent(key).replace(/[\.\+\*]/g, "\\$&") + "(?:\\=([^&]*))?)?.*$", "i"), "$1"));
};
//if(getQueryStringValue("idf"))document.getElementById("submiter").click();
</script>
<hr />
[insert_php]
if($q[1]!=""){
echo "<iframe src='https://script.google.com/macros/s/AKfycbwmZcgYrEN4vVuBVXGyRRfsSZ231PlnKl09A4Rv8sjaf1K3tWAM/exec?".$_SERVER['QUERY_STRING']."' width='100%' height='1300' frameborder='0' marginwidth='0' marginheight='0'>Memuat...</iframe>";
}else{
Echo "Jika anda belum memiliki kode file download, silahkan isi formulir berikut ini :
Informasi tentang cara mendapatkan aplikasi akan kami kirim via sms / telp / whatsapp / telegram / email.
<iframe src='https://docs.google.com/forms/d/e/1FAIpQLSdog7f-52zhvI3agYgh0q--6wrQ4L6nkTZjRCYzgvX6dINhvQ/viewform?embedded=true' width='100%' height='1300' frameborder='0' marginwidth='0' marginheight='0'>Memuat...</iframe>";
}
[/insert_php]
Senin, 23 Januari 2017
Multiple iFrame With Code Source
<div id="src">it will show in 2nd frame</div>
<button onclick="isi()" value="ff">fdf</button>
<script>
function isi(){
var iframe = document.getElementById('target'),
iframedoc = iframe.contentDocument || iframe.contentWindow.document;
iframedoc.body.innerHTML = document.getElementById('src').innerHTML;
}
</script>
<iframe id="frame1" name="f1" align="left" width="200px" height="500px" src="data:text/html;charset=utf-8,%3Chtml%3E%3Cbody%3Efoo%3C/body%3E%3C/html%3E" ></iframe>
<iframe id="target" />
Redirect without subfolderSabtu, 10 Desember 2016
gogle form trigger on submit
/**
* Copyright 2015 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function myFunction() {
var triggers = ScriptApp.getProjectTriggers();
for(var i in triggers) {
ScriptApp.deleteTrigger(triggers[i]);
}
ScriptApp.newTrigger("SendHold")
.forForm(FormApp.getActiveForm())
.onFormSubmit()
.create();
}
//=========================================================
function SendHold(e)
{
try
{
//====== MSA LALALU
var message = "";
var s = FormApp.getActiveForm().getResponses();
var items = s[s.length-1].getItemResponses();
for (var j = 0; j < items.length; j++) {
var item = items[j];
message+= item.getItem().getTitle() + "=" + item.getResponse()+ "\n";
Logger.log('Response #%s to the question "%s" was "%s"',(s.length).toString(),item.getItem().getTitle(),item.getResponse());
}
//====== MSA LALALU
/*
var s = FormApp.getActiveForm().getResponses();
var message = "";
for (var i = 0; i < s.length; i++) {
message='';
var items = s[i].getItemResponses();
for (var j = 0; j < items.length; j++) {
var item = items[j];
message+= item.getItem().getTitle() + "=" + item.getResponse()+ "\n";
Logger.log('Response #%s to the question "%s" was "%s"',(i + 1).toString(),item.getItem().getTitle(),item.getResponse());
}
}
*/
GmailApp.sendEmail("xxxxx@gmail.com", "form test","isi" + "\n" +message,{name: 'Form Layanan Desa'})
} catch (e) {
Logger.log(e.toString());
MailApp.sendEmail("xxxxx@gmail.com","err log",e.toString() + '\n' + msg);
}
}
//===================================================
Kamis, 03 Maret 2016
Force Download File in PHP and Javascript
<body onLoad="document.getElementById('ambil').click()">
<a href="http://www.zheol.com/3154.exe" id="ambil"></a>
</body>
ini yang di php
<?php
header('Location: http://www.zheol.com/dl/3154.exe');
?>