drop down and post data to data base
<p>This is a form which retrieves data from db and displays them in table. At the beginning of each row there will be a check box. If there are 10 rows fetched, I ii check 5 rows and insert them in to diff db but here when, I click drop down box data is getting in to db automatically,bcoz I use onchange event.
Any alternative to prevent this to happen.</p>

<p>Data should be inserted only when, I click submit button.</p>

<p>Any help will be appreciated </p>

<pre><code>&lt;?php 
$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("form1", $con);


error_reporting(E_ALL ^ E_NOTICE);
$nam=$_REQUEST['select1'];


 $row=mysql_query("select * from inv where name='$nam'");
while($row1=mysql_fetch_array($row))
{ 
$Name=$row1['Name'];
    $Address =$row1['Address'];
    $City=$row1['City'];
        $Pincode=$row1['Pincode'];
    $No=$row1['No'];
    $Date=$row1['Date'];
    $DCNo=$row1['DCNo'];
    $DcDate=$row1['DcDate'];
    $YourOrderNo=$row1['YourOrderNo'];
    $OrderDate=$row1['OrderDate'];
    $VendorCode=$row1['VendorCode'];
    $SNo=$row1['SNo'];
    $descofgoods=$row1['descofgoods'];
    $Qty=$row1['Qty'];
    $Rate=$row1['Rate'];
    $Amount=$row1['Amount'];
}

?&gt;

&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&gt;
&lt;title&gt;Untitled Document&lt;/title&gt;
 &lt;script type="text/javascript"&gt;
function ram(id)
   {

   var q=document.getElementById('qty_'+id).value;

   var r=document.getElementById('rate_'+id).value;

   document.getElementById('amt_'+id).value=q*r;

   }


       &lt;/script&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;form id="form1" name="form1" method="post" action=""&gt;
  &lt;table width="1315" border="0"&gt;
  &lt;script type="text/javascript"&gt;
function g()
{
form1.submit();
}
&lt;/script&gt;
  &lt;tr&gt;
    &lt;th&gt;Name&lt;/th&gt;
    &lt;th align="left"&gt;&lt;select name="select1" onchange="g();"&gt;   
      &lt;option value="" selected="selected"&gt;select&lt;/option&gt;
      &lt;?php $row=mysql_query("select Name from inv ");
while($row1=mysql_fetch_array($row))
{ ?&gt;
      &lt;option value="&lt;?php echo  $row1['Name'];?&gt;"&gt;&lt;?php echo  $row1['Name'];?&gt;&lt;/option&gt;
      &lt;?php } ?&gt;
    &lt;/select&gt;&lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;th&gt;Address&lt;/th&gt;
    &lt;th align="left"&gt;&lt;textarea name="Address"&gt;&lt;?php echo $Address;?&gt;&lt;/textarea&gt;&lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;th&gt;City&lt;/th&gt;
    &lt;th align="left"&gt;&lt;input type="text" name="City" value='&lt;?php echo $City;?&gt;' /&gt;&lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;th&gt;Pincode&lt;/th&gt;
    &lt;th align="left"&gt;&lt;input type="text" name="Pincode"  value='&lt;?php echo $Pincode;?&gt;'&gt;&lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;th&gt;No&lt;/th&gt;
    &lt;th align="left"&gt;&lt;input type="text" name="No2" value='&lt;?php echo $No;?&gt;' readonly="" /&gt;&lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;th&gt;Date&lt;/th&gt;
    &lt;th align="left"&gt;&lt;input type="text" name="Date" value='&lt;?php echo $Date;?&gt;' /&gt;&lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;th&gt;DCNo&lt;/th&gt;
    &lt;th align="left"&gt;&lt;input type="text" name="DCNo" value='&lt;?php echo $DCNo;?&gt;' readonly="" /&gt;&lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;th&gt;DcDate:&lt;/th&gt;
    &lt;th align="left"&gt;&lt;input type="text" name="DcDate" value='&lt;?php echo $DcDate;?&gt;' /&gt;&lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;th&gt;YourOrderNo&lt;/th&gt;
    &lt;th align="left"&gt;&lt;input type="text" name="YourOrderNo" value='&lt;?php echo $YourOrderNo;?&gt;' readonly="" /&gt;&lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;th&gt;OrderDate&lt;/th&gt;
    &lt;th align="left"&gt;&lt;input type="text" name="OrderDate" value='&lt;?php echo $OrderDate;?&gt;'  /&gt;&lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
&lt;th width="80"&gt;VendorCode&lt;/th&gt;
  &lt;th width="1225" align="left"&gt;&lt;input type="text" name="VendorCode"  value='&lt;?php echo $VendorCode;?&gt;' readonly="" /&gt;&lt;/th&gt;
&lt;/tr&gt;
  &lt;/table&gt;
  &lt;table width="1313" border="0"&gt;

    &lt;tr&gt;
      &lt;td width="44"&gt;&amp;nbsp;&lt;/td&gt;
      &lt;td width="71"&gt;SNO&lt;/td&gt;
      &lt;td width="527"&gt;DESCRIPTION&lt;/td&gt;
      &lt;td width="214"&gt;QUANTITY&lt;/td&gt;
      &lt;td width="214"&gt;RATE/UNIT&lt;/td&gt;
      &lt;td width="217"&gt;AMOUNT&lt;/td&gt;
    &lt;/tr&gt;
                &lt;?php $i=1;  
        $row=mysql_query("select * from inv where Name='$nam'");
while($row1=mysql_fetch_array($row))
{ 
$SNo=$row1['SNo'];
$descofgoods=$row1['descofgoods'];
    $Qty=$row1['Qty'];
    $Rate=$row1['Rate'];
    $Amount=$row1['Amount'];
?&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;input type="checkbox" name="checkbox" value="checkbox" checked="checked"/&gt;&lt;/td&gt;
      &lt;td&gt;&lt;input type="text" name="No[&lt;?php echo $i?&gt;]" value='&lt;?php echo $SNo;?&gt;' readonly=""/&gt;&lt;/td&gt;
      &lt;td&gt;&lt;input type="text" name="descofgoods[&lt;?php echo $i?&gt;]" value='&lt;?php echo $descofgoods;?&gt;' /&gt;&lt;/td&gt;
      &lt;td&gt;&lt;input type="text" name="qty[&lt;?php echo $i?&gt;]" maxlength="50000000" id="qty_&lt;?PHP echo($i) ?&gt;"/&gt;&lt;/td&gt;
      &lt;td&gt;&lt;input type="text" name="Rate[&lt;?php echo $i?&gt;]" value='&lt;?php echo $Rate;?&gt;' id="rate_&lt;?PHP echo($i) ?&gt;" onclick="ram('&lt;?PHP echo($i) ?&gt;')";&gt;&lt;/td&gt;
      &lt;td&gt;&lt;input type="text" name="Amount[&lt;?php echo $i?&gt;]"  id="amt_&lt;?PHP echo($i) ?&gt;"/&gt;&lt;/td&gt;
    &lt;/tr&gt;
     &lt;?php  $i++;} ?&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;input type="submit" value="submit" header("location:values to be brought for print page.php");/&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/table&gt;
  &lt;label&gt;&lt;/label&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;

&lt;?php 
/*error_reporting(E_ALL ^ E_NOTICE);
$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("form1", $con);


/*if(checked=checkbox)
{
mysql_query="INSERT INTO invo (Name, Address, City, Pincode, No, Date, DCNo, DcDate, YourOrderNo, OrderDate, VendorCode, SNo, descofgoods, Qty, Rate, Amount)
VALUES
('$_POST[Name]','$_POST[Address]','$_POST[City]','$_POST[Pincode]','$_POST[No]','$_POST[Date]','$_POST[DCNo]','$_POST[DcDate]','$_POST[YourOrderNo]','$_POST[OrderDate]','$_POST[VendorCode]','$_POST[SNo]','$_POST[descofgoods]','$_POST[qty]','$_POST[Rate]','$_POST[Amount]')";
}
else
{
header("location:values to be brought for print page.php");
}*/
header("ins.php");
?&gt;
</code></pre>
