PHP :
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<html>
<head>
<title>Hasil Generate Halla</title>
</head>
<body>
<div align="center">
<?php
$rows = 1;
$columns = 1;
$cells = 1;
?>
<?php $rows = (int) $_POST["JumlahRow"]; ?>
<?php $columns = (int) $_POST["JumlahColum"]; ?>
<?php $cells = (int) $_POST["JumlahCell"]; ?>
<strong>Kamu Memilih</strong> <?php echo $rows; ?> <em>baris,</em><br />
<strong>Kamu Memilih</strong> <?php echo $columns; ?> <em>kolom,</em><br />
<strong>Dan Anda Membutuhkan</strong> <?php echo $cells; ?> <em>sel,</em><br />
<br />
<br />
<?php
$width = $columns * 75;
echo "<table width=".$width." border=1>";
$rw = 0;
$cel = 1;
while ($rw < $rows && $cel <= $cells)
{
echo "<tr>";
$cl = 0;
while ($cl < $columns)
{
if ($cel <= $cells)
{
echo "<td><div align=center>".$cel."</div></td>";
$cel++;
}
$cl++;
}
echo "</tr>";
$rw++;
}
echo "</table>";
?>
</div>
</body>
</html>
HTML :
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<html>
<head>
<title>Tabel Generate Halla</title>
<font color="red">
<body bgcolor="black">
<style type="text/css">
<!--
#a1 {
width: 175px;
height: 27px;
z-index: 1;
left: 287px;
top: 190px;
}
color: red;
.b1 {
font-weight: bold;
}
-->
</style>
</head>
<body>
<script language="JavaScript" type="text/javascript">
function getmax() {
var x = parseInt(document.getElementById('JumlahRow').value);
var y = parseInt(document.getElementById('JumlahColum').value);
var z = parseInt(document.getElementById('JumlahCell').value);
var cellmax = document.getElementById('maxcells');
var total = 'N/A';
total = x * y;
cellmax.value = new String(total);
if (z > total)
{
alert('Cell Total Yang Anda Masukkan Terlalu Besar, Nilai Maksimum Cells = ' + total);
document.getElementById('CellsTotal').value = new String();
}
}
</script>
<form method="post" action="generate.php">
<h3 class="b1">Generate Sel Tabel Secara Fleksibel</h3>
<div>
<table width="301" border="0" bgcolor="red">
<tr bgcolor="yellow">
<td width="120" style="text-align:center">Baris</td>
<td width="190"><strong>= </strong>
<input name="JumlahRow" type="text" id="JumlahRow" onKeyUp="getmax();" onfocus="this.select();"/></td>
</tr>
<tr bgcolor="yellow">
<td style="text-align:center"><label>Kolom</label></td>
<td><strong>= </strong>
<input name="JumlahColum" type="text" id="JumlahColum" onKeyUp="getmax();" onfocus="this.select();"/></td>
</tr>
<tr bgcolor="yellow">
<td style="text-align:center">Sel Total </td>
<td><strong>= </strong>
<input name="JumlahCell" type="text" id="JumlahCell" onKeyUp="getmax();" onFocus="this.select();"/></td>
</tr>
<tr bgcolor="yellow">
<td style="text-align:center">Max Sel </td>
<td><strong>= </strong>
<input name="maxcells" type="text" id="maxcells" readonly="readonly" style="text-align:center"/></td>
</tr>
</table>
</div>
<div id="a1">
<input type="submit" name="Generate" value="Generate"/>
<input type="reset" name="Reset" value="Reset"/>
<img src="a.gif">
</div>
</form>
</body>
</html>
Studi Kasus_modul6
Langganan:
Posting Komentar (Atom)
0 komentar:
Posting Komentar