<?php
include "cek_session.php";
include "conn.php";
?>
<div class="post">
<h1 class="title">Data Jenis</h1>
<p class="meta"><em></em></p>
<div class="entry">
<form action="?page=simpan-jenis" method="post">
<table cellspacing="0" border="1" cellpadding="3">
<tr>
<td>Lokasi</td>
<td>Nama Jenis</td>
<td>Biaya</td>
<td>Delete</td>
</tr>
<tr>
<td><select name="lokasi[0]"/>
<option value="0">-- pilih lokasi --</option>
<option value="gudang">Gudang</option>
<option value="lapangan">Lapangan</option></select>
</td>
<td><input type="text" name="nama_jenis[0]"/></td>
<td><input type="text" name="biaya[0]"/></td>
<td><button type="button" class="del">Del</button></td>
</tr>
<tr id="last">
<td colspan="4" align="right"><button type="button" id="addRow">Add</button></td>
</tr>
</table><br />
<input type="submit" value="Simpan"/><br /><br /><br />
<tr><td><a href="?page=datajenis"><< Back</a></td></tr>
</form>
</div>
</div>
<script type="text/javascript" src=" https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript">
var i = 1;
$(function(){
$("#addRow").click(function(){
row = '<tr>'+
'<td><select name="lokasi['+i+']"/></td>'+
'<td><input type="text" name="nama_jenis['+i+']"/></td>'+
'<td><input type="text" name="biaya['+i+']"/></td>'+
'<td><button type="button" class="del">Del</button></td>'+
'</tr>';
$(row).insertBefore("#last");
i++;
});
});
$(".del").live('click', function(){
$(this).parent().parent().remove();
});
</script>
<?php
include "cek_session.php";
include "conn.php";
?>
<div class="post">
<h1 class="title">Data Jenis</h1>
<p class="meta"><em></em></p>
<div class="entry">
<form action="?page=simpan-jenis" method="post">
<table cellspacing="0" border="1" cellpadding="3">
<tr>
<td>Lokasi</td>
<td>Nama Jenis</td>
<td>Biaya</td>
<td>Delete</td>
</tr>
<tr>
<td><select name="lokasi[0]">
<option value="0">-- pilih lokasi --</option>
<option value="gudang">Gudang</option>
<option value="lapangan">Lapangan</option></select>
</td>
<td><input type="text" name="nama_jenis[0]"/></td>
<td><input type="text" name="biaya[0]"/></td>
<td><button type="button" class="del">Del</button></td>
</tr>
<tr id="last">
<td colspan="4" align="right"><button type="button" id="addRow">Add</button></td>
</tr>
</table><br />
<input type="submit" value="Simpan"/><br /><br /><br />
<tr><td><a href="?page=datajenis"><< Back</a></td></tr>
</form>
</div>
</div>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript">
var i = 1;
$(function(){
$("#addRow").click(function(){
row = '<tr>'+
'<td><select name="lokasi['+i+']">'+
'<option value="0">-- pilih lokasi --</option>'+
'<option value="gudang">Gudang</option>'+
'<option value="lapangan">Lapangan</option>'+
'</select></td>'+
'<td><input type="text" name="nama_jenis['+i+']"/></td>'+
'<td><input type="text" name="biaya['+i+']"/></td>'+
'<td><button type="button" class="del">Del</button></td>'+
'</tr>';
$(row).insertBefore("#last");
i++;
});
});
$(".del").live('click', function(){
$(this).parent().parent().remove();
});
</script>
karena kode diatas menggunakan jquery dari google CDN https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js