By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,965 Members | 1,702 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,965 IT Pros & Developers. It's quick & easy.

onchange behaviour save my data

P: 22
Hy Guys , Can anybody help me ?
I try to make small web database in my unit.
Some of fields have on change behaviour to get other data that automatically filled other text field. But when i try to hit "enter" after i fill text field , its automatically save data in my table database . I just want to save data after , i click "save" button.
[PHP]<?php
include"session.php";
mb_http_input("iso-8859-1");
mb_http_output("iso-8859-1");
$tgl=$_POST["tgl"];
$bln=$_POST["bulan"];
$thn=$_POST["tahun"];
$hari=mktime(0,0,0,$bln,$tgl,$thn);
$harike=date("N",$hari);
$angkabln=date("m",$hari);
$namabln=date("F",$hari);
$namathn=date("Y",$hari);
$tanggal=date("d",$hari);
$year=date("Ymd",$hari);
$fltdep=$_POST["fltdep"];
$reg=$_POST["reg"];
$save=$_POST["save"];
$categori=$_POST["categori"];
$std=$_POST["std"];
$gate=$_POST["gate"];
$bay=$_POST["bay"];
$configc=$_POST["configc"];
$configy=$_POST["configy"];
$atd=$_POST["atd"];
$dl01=$_POST["dl01"];
$dl02=$_POST["dl02"];
$jam01=$_POST["jam01"];
$min01=$_POST["min01"];
$dur1=mktime($jam01,$min01,0,0,0,0);
$dur01=date("H:i",$dur1);
$jam02=$_POST["jam02"];
$min02=$_POST["min02"];
$dur2=mktime($jam02,$min02,0,0,0,0);
$dur02=date("H:i",$dur2);
$ttljam=$jam01+$jam02;
$ttlmin=$min01+$min02;
$ttl=mktime($ttljam,$ttlmin,0,0,0,0);
$ttldur=date("H:i",$ttl);
$btnsave=$_POST["save"];
//cek registrasi//
include("../koneksi.php");
$cek_reg=mysql_query("select *from tblacft where registrasi='$reg'",$koneksi)or die(mysql_error());
$dpt_reg=mysql_fetch_array($cek_reg);
//cek skedule//
$cek_std=mysql_query("select * from tblskeddep where day='$harike' and fltnbr='$fltdep'",$koneksi)
or die(mysql_error());
$row_std=mysql_fetch_array($cek_std);
//input data//
if(isset($act)){
$tambah="INSERT INTO tbldataflt(airlinekode,day,tgl,bulan,tahun,fltdep, reg,type,gate,bay,categori,configc,configy,ahan,pa x,otp,
std,atd,del01,del02,dur01,dur02,ttldur) VALUES('$kode','$harike','$year','$namabln','$nama thn','$fltdep','$reg','$dpt_reg[type]','$gate','$bay','$categori1',
'$dpt_reg[configc]','$dpt_reg[configy]','$ahan1','$pax1','$otp1','$row_std[std]','$atd','$dl01','$dl02','$dur01','$dur02',
'$ttldur')";
$simpan=mysql_query($tambah,$koneksi)or die (mysql_error());
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<table width="894" height="828" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="1148" height="31" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
</tr>
<tr>
<td height="797" align="left" valign="top"><form name="form6" method="post" action="<?php _SELF ?>">
<table style="clear:both" width="396" border="1" cellpadding="0" cellspacing="1" bordercolor="#000000">
<!--DWLayoutTable-->
<tr>

<td width="125"><span class="style17">Date(dd/mm/yy)</span></td>
<td width="33"><input name="tgl" type="text" id="tgl" value="<?php echo"$tanggal" ?>" size="4"></td>
<td width="42"><input name="bulan" type="text" id="bulan" value="<?php echo"$angkabln" ?>" size="5"></td>
<td width="73"><input name="tahun" type="text" id="tahun" onChange="this.form.submit" value="<?php echo"$namathn" ?>" size="8"></td>
<td width="43" align="center"><span class="style17">Day</span></td>
<td width="59"><span class="style17">
<input name="hari" type="text" id="hari" value="<?php echo"$harike" ?>" size="4">
</span></td>
</tr>
</table>
<table width="894" height="231" border="1" cellspacing="1" bordercolor="#010101" bgcolor="#E0DFE3">
<!--DWLayoutTable-->
<tr>
<td colspan="17" bgcolor="#7BA0DF"><div align="center" class="style18">Departure Flight </div></td>
</tr>
<tr>
<td colspan="2" class="style21">Flight Number </td>
<td width="107"><div align="left">
<input name="fltdep" type="text" value="<?php echo"$fltdep" ?>" size="16" onChange="this.form.submit">
</div></td>
<td width="65" colspan="5" class="style21"><!--DWLayoutEmptyCell-->&nbsp;</td>
<td colspan="8" class="style21">A/C Configuration</td>
</tr>
<tr>
<td height="26" colspan="2" class="style21"><span class="style21">Acft Registration</span></td>
<td><input name="reg" type="text" id="reg" value="<?php echo"$reg"?>" size="16"></td>
<td colspan="5" class="style21">&nbsp;&nbsp;</td>
<td colspan="3" align="center" valign="middle" bgcolor="#F8EDAD" class="style21"><div align="center">C</div></td>
<td bgcolor="#F8EDAD" class="style21"><div align="center">Y</div></td>
<td colspan="3" class="style21">&nbsp;&nbsp;</td>
</tr>
<tr>
<td colspan="2" class="style21">A/C Type</td>
<td><input name="tipe" type="text" id="tipe" value="<?php echo"$dpt_reg[type]"?>" size="16"></td>
<td colspan="2" align="center" bgcolor="#F8EDAD" class="style21">A/C Category</td>
<td colspan="3" class="style21"><input name="categori" type="radio" value="1">
W/B</td>
<td colspan="3" align="center" valign="top" class="style21"><input name="configc" type="text" id="configc" value="<?php echo"$dpt_reg[configc]"?>" size="7"></td>
<td width="60" align="center" class="style21"><input name="configc2" type="text" id="configc2" value="<?php echo"$dpt_reg[configy]"?>" size="7"></td>
<td width="231" align="center" class="style21"><!--DWLayoutEmptyCell-->&nbsp;</td>
<td colspan="2" class="style21"><!--DWLayoutEmptyCell-->&nbsp;</td>
</tr>
<tr>
<td colspan="2" bgcolor="#F8EDAD" class="style21">STD</td>
<td><input name="std" type="text" id="std" value="<?php echo"$row_std[std]" ?>" size="16"></td>
<td colspan="2" align="center" class="style21"> ATD</td>
<td colspan="3" class="style21"><input name="atd" type="text" id="atd" value="<?php echo"$atd" ?>" size="12"></td>
<td colspan="8" valign="top" class="style21"><!--DWLayoutEmptyCell-->&nbsp;</td>
</tr>
<tr>
<td colspan="2" class="style21">Gate number </td>
<td><input name="gate" type="text" id="gate" value="<?php echo"$gate" ?>" size="16"></td>
<td colspan="2" align="center" class="style21">Stand Number</td>
<td colspan="3" class="style21"><input name="bay" type="text" id="bay" value="<?php echo"$bay" ?>" size="12"></td>
<td colspan="8" valign="top" class="style21"><!--DWLayoutEmptyCell-->&nbsp;</td>
</tr>
<tr>
<td width="48" height="13" class="style21">Del01</td>
<td width="71" class="style21"><div align="center">
<input name="dl01" type="text" id="dl01" value="<?php echo"$dl01" ?>" size="4">
</div></td>
<td colspan="2" align="center" class="style21">Duration01(HH/MM)</td>
<td class="style21"><input name="jam01" type="text" id="jam01" value="<?php echo"$jam01" ?>" size="5"></td>
<td width="42" align="center" valign="middle" class="style21"><input name="min01" type="text" id="min01" value="<?php echo"$min01" ?>" size="5"></td>
<td colspan="11" align="center" class="style21"><div align="left"><span class="style13">Must be filled with zero if no delay </span></div></td>
</tr>
<tr>
<td height="13" class="style21">Del 02 </td>
<td height="13" class="style21"><div align="center">
<input name="dl02" type="text" id="dl02" value="<?php echo"$dl02" ?>" size="4">
</div></td>
<td colspan="2" align="center" class="style21">Duration02(HH/MM)</td>
<td width="64" class="style21"><input name="jam02" type="text" id="jam02" value="<?php echo"$jam02" ?>" size="5"></td>
<td align="center" valign="middle" class="style21"><input name="min02" type="text" id="min02" value="<?php echo"$min02" ?>" size="5"></td>
<td colspan="11" align="center" class="style21"><div align="left">
<div align="left"><span class="style13">Must be filled with zero if no delay </span></div>
</div></td>
</tr>
<tr>
<td height="13" colspan="2" class="style21">Total Duration </td>
<td colspan="2" class="style21"><div align="center">
<input name="ttldur" type="text" id="ttldur" value="<?php echo"$ttldur" ?>" size="12">
</div></td>
<td colspan="13" class="style21"><!--DWLayoutEmptyCell-->&nbsp;</td>
</tr>
</table>
<table width="894" border="1" cellspacing="1" bordercolor="#000000">
<tr>
<td width="306">&nbsp;</td>
<?php if($act!=="save"){?>
<td width="118" align="center"><input name="save" type="submit" id="save" value="Save">
<?php } ?></td>
<td width="88">&nbsp;</td>
<td width="359">&nbsp;</td>
</tr>
</table>
</form></td>
</tr>
</table>
</body>
</html>[/PHP]
Mar 1 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.