我的按钮出了什么问题?

时间:2017-05-05 10:18:26

标签: php

`<div class="tab-content">
    <div class="row">
        <div class="col-lg-6">
            <form method="post" data-toggle="modal" enctype="multipart/form-data" action="data/pegawai/proses.php">
                <div class="form-group">
                    <label>NIP</label>
                    <input class="form-control" name="nip" type="text" value="<?php echo $r['nip'];?>" readonly="">
                </div>
                <div class="form-group">
                    <label>Nama Lengkap</label>
                    <input class="form-control" type="text" value="<?php echo $r['nm_pegawai'];?>" name="nama" placeholder="Nama Lengkap" autofocus="" required="">
                </div>
                <div class="form-group">
                    <label>Jenis Kelamin</label>
                    <div class="radio">
                        <label class="radio-inline">
                            <input type="radio" name="jk" id="optionsRadiosInline1" value="Laki-laki" <?php $ob->cek("Laki-laki",$r['jenis_kelamin'],"radio") ?>>Laki-laki
                        </label>
                        <label class="radio-inline">
                            <input type="radio" name="jk" id="optionsRadiosInline2" value="perempuan" <?php $ob->cek("Perempuan",$r['jenis_kelamin'],"radio") ?>>perempuan
                        </label>
                    </div>
                </div>
                <div class="form-group">
                    <label>Tempat Lahir</label>
                    <input class="form-control" type="text" value="<?php echo $r['tempat_lahir'];?>" name="tmp_lahir" placeholder="Tempat Lahir" required="">
                </div>
                <div class="form-group">
                    <label>Tanggal Lahir</label>
                    <input type="date" name="tgl_lahir" value="<?php echo $r['tanggal_lahir'];?>" class="form-control" placeholder="Tanggal Lahir" required="">
                </div>
                <div class="form-group">
                    <label>Agama</label>
                    <select class="form-control" name="agama" required="">
                        <option <?php $ob->cek("Islam",$r['agama'],"select") ?> value="Islam">Islam</option>
                        <option <?php $ob->cek("Kristen",$r['agama'],"select") ?> value="Kristen">Kristen</option>
                        <option <?php $ob->cek("Katholik",$r['agama'],"select") ?> value="Katholik">Katholik</option>
                        <option <?php $ob->cek("Protestan",$r['agama'],"select") ?> value="Protestan">Protestan</option>
                        <option <?php $ob->cek("Hindu",$r['agama'],"select") ?> value="Hindu">Hindu</option>
                        <option <?php $ob->cek("Budha",$r['agama'],"select") ?> value="Budha">Budha</option>
                    </select>
                </div>
                <div class="form-group">
                    <label>Alamat</label>
                    <textarea class="form-control" name="alamat" rows="3" placeholder="Alamat Lengkap" required=""><?php echo $r['alamat'];?></textarea>
                </div>
            </div>
            <div class="col-lg-6">    
                <div class="form-group">
                    <label>Nomor Telepon</label>
                    <input class="form-control" type="text" value="<?php echo $r['no_telp'];?>" name="telp" onkeypress="return isNumberKey(event)" maxlength="15" placeholder="Nomor telepon" required="">
                </div>
                <div class="form-group">
                    <label>Tahun Masuk</label>
                    <input class="form-control" type="text" value="<?php echo $r['tahun_masuk'];?>" name="thn_masuk" placeholder="Tahun Masuk" onkeypress="return isNumberKey(event)" maxlength="4" required="">
                </div>
                <div class="form-group">
                    <label>Bagian</label>
                    <select class="form-control" name="bagian" required="">
                        <option <?php $ob->cek("Teller",$r['bagian'],"select") ?> value="Teller">Teller</option>
                        <option <?php $ob->cek("CSO",$r['bagian'],"select") ?> value="CSO">CSO</option>
                        <option <?php $ob->cek("BO",$r['bagian'],"select") ?> value="BO">BO</option>
                    </select>
                </div>
                <div class="form-group">
                    <label>Cabang</label>
                    <?php
                        echo '<select class="form-control" name="cabang" required="">';

                        $query=mysql_query("
                            SELECT * 
                            FROM bank");
                        while($entry1=mysql_fetch_array($query))
                            {
                            echo "<option"; 
                            if($entry1['kd_bank']==$r['kd_bank']){echo " selected=selected";} 
                            echo " value='".$entry1['kd_bank']."'>" . $entry1['nm_bank'] . "</option>";
                            }
                        echo "</select>";
                    ?>
                </div>
                <div class="form-group">
                    <label>Kata Sandi</label>
                    <input class="form-control" type="password" value="<?php echo $r['password']?>" name="password" placeholder="Kata Sandi">
                </div>
            </div>
        <!-- /.col-lg-6 (nested) -->
    </div> 
    <!-- /.row (nested) -->
    <div class="modal-footer">
        <button type="button" name="ubah" class="btn btn-primary">Ubah</button>
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
    </div>
    </form>
</div>    `

我的源代码,我的按钮无法激活,如何解决?

谢谢 Pandhu

1 个答案:

答案 0 :(得分:1)

将您的按钮类型设置为“提交”,如下所示。

<button type="submit" name="ubah" class="btn btn-primary">Ubah</button>

否则您也可以将其保留为按钮,但在这种情况下,您需要在按钮上使用ajax(javascript)和onclick事件,例如:

<button type="button" name="ubah" class="btn btn-primary" onclick="save()">Ubah</button>

其中save()是javascript中的一些函数,您将创建该函数来保存表单数据。