can somebody check my code...i really don't know what's the problem is...

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<style type="text/css">
<!--
body {
    margin-top: 50mm;
}
-->
</style>
<script src="gen_validatorv4.js" type="text/javascript"></script> 
<script type="text/javascript">
function upperCase()
{
var x=document.getElementById("specification").value;
document.getElementById("specification").value=x.toUpperCase();

var x=document.getElementById("permohonanNo").value;
document.getElementById("permohonanNo").value=x.toUpperCase();
}
</script>
<script type="text/javascript">
function calculateTotalPrice(){
    var price = parseFloat(document.borg_prolehan.price_unit.value);
    var kuantiti = parseInt(document.borg_prolehan.quantity.value);

    //alert(book_price);
    var total = price * kuantiti;

    document.borg_prolehan.total_price.value = total.toFixed(2);
}
</script>
</head>

<body bgcolor="#99ccff">
<div align="center">
<form id="borg_prolehan" name="borg_prolehan" method="post" action="fill_form.php?submit=yes">

<p>
<span id="spanOutput" style="border: 1px solid #000; padding: 3px;"> </span>
</p>
<table border="1" id="tblSample">
  <tr>
    <td colspan="6" align="center">PERMOHONAN PEROLEHAN : <input type="text" name="permohonanNo" id="permohonanNo" onblur="upperCase()" /></td>
    </tr>
    <tr>
      <td width="316" colspan="6" align="center">NAMA JBT/BHG : 
        <select name="bahagian" id="bahagian">
          <option value="0"></option>
<option value="Bahagian Teknologi Maklumat">Bahagian Teknologi Maklumat</option>
<option value="Bahagian Audit Dalaman">Bahagian Audit Dalaman</option>
<option value="Bahagian Kawalan Bangunan">Bahagian Kawalan Bangunan</option>
<option value="Bahagian Kejuruteraan">Bahagian Kujuruteraan</option>
<option value="Bahagian Kewangan">Bahagian Kewangan</option>
<option value="Bahagian Khidmat Masyarakat">Bahagian Khidmat Masyarakat</option>
<option value="Bahagian Landskap">Bahagian Landskap</option>
<option value="Bahagian Perundangan dan Penguatkuasaan">Bahagian Perundangan dan Penguatkuasaan</option>
<option value="Bahagian Penilaian">Bahagian Penilaian</option>
<option value="Bahagian Perancang Bandar">Bahagian Perancang Bandar</option>
<option value="Bahagian Perhubungan Awam">Bahagian Perhubungan Awam</option>
<option value="Bahagian Perlesenan">Bahagian Perlesenan</option>
<option value="Bahagian Perolehan dan Stor">Bahagian Perolehan dan Stor</option>
<option value="Bahagian Projek">Bahagaian Projek</option>
<option value="Unit Pusat Setempat">Unit Pusat Setempat</option>
          </select>
        </td>
      </tr>
  <tr>
    <th>Bil.</th>
    <th>Spesifikasi</th>
    <th>Harga Seunit</th>
    <th>Kuantiti</th>
    <th>Jumlah (RM)</th>
  </tr>
  <tr>
    <td align="center">1</td>
    <td>
    <input type="text" name="specification" id="specification" size="40" onblur="upperCase()" />
    </td>
    <td>
    <input type="text" name="price_unit" id="price_unit" size="20" />
    </td>
    <td>
    <input type="text" name="quantity" id="quantity" size="10" onblur="calculateTotalPrice();"/>
    <input name="status" type="hidden" value="PENDING" />
    </td>
    <td>
    <input type="text" name="total_price" id="total_price" size="20" readonly />
    </td>
  </tr>
  <tr>
    <td align="center">2</td>
    <td>
    <input type="text" name="specification" id="specification" size="40" onblur="upperCase()" />
    </td>
    <td>
    <input type="text" name="price_unit" id="price_unit" size="20" />
    </td>
    <td>
    <input type="text" name="quantity" id="quantity" size="10" onblur="calculateTotalPrice();"/>
    <input name="status" type="hidden" value="PENDING" />
    </td>
    <td>
    <input type="text" name="total_price" id="total_price" size="20" readonly />
    </td>
  </tr>
  <tr>
    <td align="center">3</td>
    <td>
    <input type="text" name="specification" id="specification" size="40" onblur="upperCase()" />
    </td>
    <td>
    <input type="text" name="price_unit" id="price_unit" size="20" />
    </td>
    <td>
    <input type="text" name="quantity" id="quantity" size="10" onblur="calculateTotalPrice();"/>
    <input name="status" type="hidden" value="PENDING" />
    </td>
    <td>
    <input type="text" name="total_price" id="total_price" size="20" readonly />
    </td>
  </tr>
</table>
<p>
<input type="submit" name="submit" id="submit" value="Mohon" />
<input type="reset" name="padam" id="padam" value="Padam" />
</p>
</form></div></body></html>

i try to add 3 data using same name, but it just add one data which is the first textbox row...anybody please help me....

What exactly do you want you code to do and not doing it ? … use code marks for code …

i develop a form that user can order something...i've prepare 3 textbox for user if the user want to order more than one...the problem is, when i click submit button, it just insert data from the first row of textbox...the other 2 did not insert into database... this is the code for insert process...

<?php
include('config.php');

	if($_POST)
	{ $permohonanNo = $_POST["permohonanNo"];
	  $bahagian = $_POST["bahagian"];
	  $specification = $_POST["specification"];
	  $quantity = $_POST["quantity"];
	  $price_unit = $_POST["price_unit"];
	  $total_price = $_POST["total_price"];

	function simpanDataPermohonan($permohonanNo, $bahagian, $specification, $quantity, $price_unit, $total_price){	
	$sql = "INSERT INTO permohonan (permohonanNo, bahagian, specification, quantity, price_unit, total_price)
			       VALUES ('$permohonanNo', '$bahagian', '$specification', '$quantity', '$price_unit', '$total_price')";
	//echo $sql;
	$query = mysql_query($sql) or die("Error: " . mysql_error());
	}
	}
	
	function gagal()
	{
		echo"<script language='Javascript'>
			alert('Maaf..data gagal disimpan');
			location.href='fill_form.php';
			</script>";
    }
	
	function berjaya()
	{
		echo"<script language='Javascript'>
			alert('Data telah disimpan..');
			location.href='viewmohon.php';
			</script>";
    }

if(isset($_POST['submit'])){
$permohonanNo = isset ($_POST['permohonanNo']) ? $_POST['permohonanNo'] : '';
$bahagian = isset ($_POST['bahagian']) ? $_POST['bahagian'] : '';		
$specification = isset($_POST['specification']) ? $_POST['specification'] : '';
$quantity = isset($_POST['quantity']) ? $_POST['quantity'] : '';
$price_unit = isset($_POST['price_unit']) ? $_POST['price_unit'] : '';
$total_price = isset($_POST['total_price']) ? $_POST['total_price'] : '';

if(is_array($errors)){
   gagal();
	while (list($key, $value) = each($errors)){			
		echo "<span class=\"error\">".$value."</span><br />";
	}
}
else
{
	simpanDataPermohonan($permohonanNo, $bahagian, $specification, $quantity, $price_unit,  $total_price);
	simpanDataPermohonanNO($permohonanNo);
	berjaya();
}}?>

do you have any knowledge of PHP? what is the simpanDataPermohonan function ? .... berjaya ???? I understand that you don't have any clue what you are writing ... why not trying that first ?

simpanDataPermohonan is just a function name...

Just using the print_r for your query to make sure your data insert is available

Member Avatar

diafol

show the form code

Re : show the form code

its alright...i've got the solution...thanks for helping....