Jumat, 26 September 2025

Sweet Alert



Download library weetalert.min.js, letakkan dalam satu folder sejajar index !

 https://drive.google.com/drive/folders/1uXhLjQv998HlVhtzObOPCCt6TbvPhaCV?usp=sharing


Misal letakkan di kode:

<?php
require_once "sweet.php";
echo "<script>Message2('Sukses Logout','login.php',' terimakasih atas kunjungannya...See You Later...');</script>";

 ?>



isi dari file sweet.php
sweet.php
<head>
  <script src="jquery-3.3.1.min.js"></script>
  <script src="sweetalert.min.js"></script>
</head>

    <script type="text/javascript">
        function Message1(myheader,mylink,myvar) {
           swal({
                 title:myheader,
                text: myvar,
                icon: "success",
                button: true

            }).then((result) => {
document.location.href=mylink;
});
        }
    </script>
    <script type="text/javascript">
        function Message2(myheader,mylink,myvar) {
           swal({
               title:myheader,
                text: myvar,
                icon: "warning",
                button: true

            }).then((result) => {
document.location.href=mylink;
});
        }
    </script>
    <script type="text/javascript">
        function welcome() {
           swal({
                title: "Uji Kompetensi <?php echo $header;?>",
                text: "Yth: aaaa \n.............................................................\nTerimakasih Atas Partisipasinya dan Selamat mengerjakan...",
                icon: "success",
                button: true
            
}).then((result) => {
document.location.href='iot_.php';
})
    }
    </script>
<script type="text/javascript">
        function contoh(myvar1,mylink) {
           swal({
                title: "Uji Kompetensi <?php echo $header;?>",
               text: "Yth: "+myvar1+" \n.............................................................\nTerimakasih Atas Partisipasinya dan Selamat mengerjakan...",
                icon: "success",
                button: true

            }).then((result) => {
document.location.href=mylink;
});
        }
    </script>

JS Enable Tanggal YAD

 <form action="" method="post" enctype="multipart/form-data">
    <table class="table">
        <tr>
            <td><label for="tanggal_perawatan">Tanggal Perawatan</label></td>
            <td>:</td>
            <td width="683">
                <input style="width: 350px" required name="tanggal_perawatan" class="form-control" type="date" id="tanggal_perawatan" value="<?php echo $tanggal_perawatan; ?>" size="25" />
            </td>
        </tr>
    </table>
</form>

<script>
    // Dapatkan elemen input tanggal
    const inputTanggal = document.getElementById('tanggal_perawatan');

    // Buat objek tanggal hari ini
    const hariIni = new Date();
    
    // Tambahkan 1 hari ke tanggal hari ini
    hariIni.setDate(hariIni.getDate() + 1);

    // Format tanggal besok menjadi 'YYYY-MM-DD'
    const tahun = hariIni.getFullYear();
    const bulan = (hariIni.getMonth() + 1).toString().padStart(2, '0');
    const tanggal = hariIni.getDate().toString().padStart(2, '0');

    // Tanggal minimal diatur ke tanggal besok
    const tanggalMinimal = `${tahun}-${bulan}-${tanggal}`;

    // Set atribut 'min' pada input tanggal
    inputTanggal.setAttribute('min', tanggalMinimal);
</script>




Jika tanggal hari ini tetap enabled:

<script>
    // Dapatkan elemen input tanggal berdasarkan ID
    const inputTanggal = document.getElementById('tanggal_perawatan');

    // Buat objek tanggal hari ini
    const hariIni = new Date();

    // Format tanggal menjadi 'YYYY-MM-DD' yang dibutuhkan oleh input date
    const tahun = hariIni.getFullYear();
    const bulan = (hariIni.getMonth() + 1).toString().padStart(2, '0');
    const tanggal = hariIni.getDate().toString().padStart(2, '0');

    const tanggalMinimal = `${tahun}-${bulan}-${tanggal}`;

    // Set atribut 'min' pada input tanggal untuk membatasi tanggal yang bisa dipilih
    inputTanggal.setAttribute('min', tanggalMinimal);
</script>









Sweet Alert

Download library weetalert.min.js, letakkan dalam satu folder sejajar index !  https://drive.google.com/drive/folders/1uXhLjQv998HlVhtzObOPC...