Tuesday, September 30, 2014

Check Box

Pada tulisan kali ini saya akan meemberitahukan cara untuk membuat check box. Ketikan kode berikut:

Untuk PHPnya ketikan kode berikut:

1
2
3
4
5
<?php 
    @$borrow1 = $_POST['borrow1'];
    @$borrow2 = $_POST['borrow2'];
    @$borrow3 = $_POST['borrow3'];
?>



Untuk HTMLnya ketikan kode berikut:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<!DOCTYPE html>
<html>
    <head>
        <title></title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    </head>
    <body>
        <form action="checkbox.php" method="POST">
            <center>
                
                <table>
                <tr>
                <td>Borrow</td>
                <td>:</td>
                <td><input name="borrow1" type="checkbox" value="Document" <?php if($borrow1 == "Document"){echo 'checked';} ?> />Document
                <td><input name="borrow2" type="checkbox" value="Electronic" <?php if($borrow2 == "Electronic"){echo 'checked';} ?> />Electronic
                <td><input name="borrow3" type="checkbox" value="Vehicle" <?php if($borrow3 == "Vehicle"){echo 'checked';} ?> />Vehicle
                </td>
            </tr>
            <tr>
                <td><input type="submit" name="submit" value="SUBMIT"/></td>
            </tr>
            <tr>
                <td></td>
                <td></td>
                <td><?php echo $borrow1."<br/>"; ?>
                    <?php echo $borrow2."<br/>"; ?>
                    <?php echo $borrow3."<br/>"; ?>
                </td>
            </tr>
            </table>
                
            </center>
            
        </form>
    </body>
</html>



Keseluruhan kodenya adalah sebagai berikut:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php 
    @$borrow1 = $_POST['borrow1'];
    @$borrow2 = $_POST['borrow2'];
    @$borrow3 = $_POST['borrow3'];
?>


<!DOCTYPE html>
<html>
    <head>
        <title></title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    </head>
    <body>
        <form action="checkbox.php" method="POST">
            <center>
                
                <table>
                <tr>
                <td>Borrow</td>
                <td>:</td>
                <td><input name="borrow1" type="checkbox" value="Document" <?php if($borrow1 == "Document"){echo 'checked';} ?> />Document
                <td><input name="borrow2" type="checkbox" value="Electronic" <?php if($borrow2 == "Electronic"){echo 'checked';} ?> />Electronic
                <td><input name="borrow3" type="checkbox" value="Vehicle" <?php if($borrow3 == "Vehicle"){echo 'checked';} ?> />Vehicle
                </td>
            </tr>
            <tr>
                <td><input type="submit" name="submit" value="SUBMIT"/></td>
            </tr>
            <tr>
                <td></td>
                <td></td>
                <td><?php echo $borrow1."<br/>"; ?>
                    <?php echo $borrow2."<br/>"; ?>
                    <?php echo $borrow3."<br/>"; ?>
                </td>
            </tr>
            </table>
                
            </center>
            
        </form>
    </body>
</html>


Tampilan akhirnya adalah sebagai berikut:



No comments:

Post a Comment