如何根据表单序列化中的选定值提供警报

时间:2017-06-12 14:11:41

标签: javascript ajax form-serialize

我想提醒我在表单上选择的内容。

这是我在myform上的下拉列表

<!-- PEMILIHAN TEMA -->
                <?php 
                echo "<center><div style='display:none;' id='formtugas'>";
                echo "<select id='tema' name='tema' class='form-control5' required>";
                $querytema = mysqli_query($dbh,"SELECT KodeTema, NamaTema FROM tema WHERE KodeKelas='1'");
                echo "<option selected disabled>Pilih Tema berdasarkan Tugas</option>";
                while ($ambiltema = mysqli_fetch_array($querytema))
                {
                    echo "<option value='".$ambiltema['NamaTema']."'>".$ambiltema['NamaTema']."</option>";
                }
                    echo "</select>";
                    echo "<br>";
                ?>  
                <!-- END -->

                <!-- PEMILIHAN MATA PELAJARAN -->
                <?php 
                echo "<center>";
                echo "<select id='mapel' name='mapel' class='form-control5' required>";
                $querymapel = mysqli_query($dbh,"SELECT KodeMapel, NamaMapel FROM mapel");
                echo "<option selected disabled>Pilih Mata Pelajaran berdasarkan Tugas</option>";
                while ($ambilmapel = mysqli_fetch_array($querymapel))
                {
                    echo "<option value='".$ambilmapel['NamaMapel']."'>".$ambilmapel['NamaMapel']."</option>";
                }
                    echo "</select>";
                    echo "</div><br>";
                ?>  
                <!-- END -->

这是我的ajax javascript

$(document).ready(function(e) {
$("#myform").submit(function(e) {

    $.ajax({
           type: "GET",
           url: "Pengetahuan/daftarTugas.php",
           data: 
                $("#myform").serialize(), 
           success: function(data)
           {
               alert("Pilihan : " + $("#myform").serialize());
               $('#tabelTugas').html(data); 
               $('#dataTable').DataTable();                
           }
         });

    e.preventDefault(); // avoid to execute the actual submit of the form.
}); });

此警报就像这样给了我 Alert based on that code

我想要提醒节目 &#34; Pilihan:NamaTema + NamaMapel&#34;

0 个答案:

没有答案