I' using php ,mysql and ajax. I want to add vehicles details to the database. data adding part is working. But the problem is text fields are not clear after the submit. This is my code
Code:
<?php
session_start();
require_once ('dbconnect.php');
require_once ('commonFunctions.php');
?>
<script language="javascript" src="ajax.js"></script>
</head>
<div id="addvehicle"></div>
<?
//----------------get selecteddropdown value from ajax and pass to the getVehicleModel Fn in commonFunction.php-----
$make= "";
if(isset($_GET['Submit'])==2){
$make=$_GET['make'];
getVehicleModel($make);
return;
}
if(isset($_GET['St'])==1){
$make=$_GET['make'];
$model=$_GET['model'];
$type=$_GET['type'];
$year=$_GET['year'];
$month=$_GET['month'];
$fuel=$_GET['fuel'];
$transmission=$_GET['transmission'];
$displacement=$_GET['displacement'];
$color=$_GET['color'];
$milage=$_GET['milage'];
$price=$_GET['price'];
$other=$_GET['other'];
//---------------------insert data to vehicles table-------------------------------------------
$sql = "INSERT INTO vehicles VALUES('','$make','$model','$type','$year','$month','$fuel','$transmission','$color','$price','$displacement','$milage','$other')";
$result = mysql_query($sql);
if (!$result)
{
echo "Error in SQL query: " . mysql_error();
}
else{
echo "success"; }
return;
}
?>
<table width="566" height="100%" border="0" align="center" cellpadding="0" cellspacing="0" >
<tr>
<td>
<table cellspacing="5"><br />
<tr><td colspan="2"></td></tr>
<tr>
<td>Make :</td>
<td>
<?php getVehicleMake();
?>
</td>
</tr>
<tr>
<? //------------------ this is reciveing ajax sending selected vahicle make-------------------------- ?>
<!--<div id='txtHint'></div>-->
<td>Model :</td>
<td>
<div id='txtHint'>
<? getVehicleModel($make);
?>
</div>
</td>
</tr>
<tr>
<td>Type :</td>
<td colspan="3">
<? getVehicleType();?>
</td>
</tr>
<tr>
<td>Other :</td> <td><textarea id="Other" cols=40 rows=3 name="Other" class="normalTxt" ></textarea></td>
</tr>
<tr>
</tr>
<tr>
<td align="right" colspan="2"><input type="image" class="btn" src="images/addBtn.jpg" alt="Search" name="submit" onclick="addVehicle(); return false;" />
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
Comment