<script type="text/javascript">
function populateHarga() {
var x=document.getElementById("barang").value;
document.getElementById("harga").value=x;
var y=document.getElementById('barang')[document.getElementById('barang').selectedIndex].innerHTML;
document.getElementById('nama_brg').value=y;
}
function populateTotal()
{
var y=document.getElementById("jumlah").value;
var x=document.getElementById("harga").value;
document.getElementById("totalnya").value=x*y;
}
</script>
<body>
<p>
<?php
mysql_connect("localhost","root","");
mysql_select_db("stageco");
?>
<table border="1" cellpadding="0" cellspacing="0">
<?php
$nama_b=$_GET['nama_brg'];
$harga_b=$_GET['harga'];
$jumlah_b=$_GET['jumlah'];
$total_b=$_GET['totalnya'];
if($nama_b!="")
{
mysql_query("INSERT INTO temp('t_nama','t_harga','t_jumlah','t_total') VALUES('$nama_b','$harga_b','$jumlah_b','$total_b')");
}
$result=mysql_query("SELECT * FROM temp");
$i = 0;
while ($row = mysql_fetch_array($result)) {
if ($i > 0) {
echo "<tr valign='bottom'>";
echo "<td bgcolor='#ffffff' height='1'></td>";
echo "</tr>";
}
echo "<tr valign='middle'>";
echo "<td class='tabval'><width='10' height='20'></td>";
echo "<td class='tabval'><b>".$row['t_nama']."</b></td>";
echo "<td class='tabval'>".$row['t_jumlah']." </td>";
echo "<td class='tabval'>".$row['t_harga']." </td>";
echo "<td class='tabval'>".$row['t_total']." </td>";
echo "<td class='tabval'></td>";
echo "</tr>";
$i++;
}
echo "<tr valign='bottom'>";
echo "<td bgcolor='#fb7922' colspan='6'></td>";
echo "</tr>";
?>
</table>
<h2>add Entry</h2>
<?
echo "<form action=phonebook.php method=get>";
$get = mysql_query("select * from inventori");
echo"<table width=649 border=0 cellspacing=3 cellpadding=3>";
echo"<tr>";
echo"<td width=99>Nama Produk</td>";
echo"<td width=198><select id=barang onchange=populateHarga()>";
echo "<option></option>";
while($list=mysql_fetch_array($get))
{
echo "<option value='$list[harga]'>$list[nama_barang]</option>";
}
echo"</select></td>";
echo"</tr>";
echo"<tr>";
echo"<td>Jumlah</td>";
echo"<td><input id=jumlah name=jumlah type=text size=12 onblur=populateTotal() /></td>";
echo"</tr>";
echo"<tr>";
echo"<td>Harga</td>";
echo"<td>";
echo"<input id=harga name=harga type=text />";
echo"</td>";
echo"</tr><tr><td>";
echo"Total :";
echo"</td><td>";
echo"<input type=text name=totalnya id=totalnya /> </td></tr>";
echo"<input type=text name=nama_brg id=nama_brg />";
echo"<tr>";
echo"<td colspan=2><div align=right><input type=submit value=Next />
<input type=reset id=batal value=Reset />
</div></td></tr>";
echo"</table></form>";
?>
</body>
</html>
My problem is i want to insert the DB from a form i make in the same page.. but it doesnt work at all..thanks b4