Almost i have written code for adding a row which contain many "<select>" menu which takes value from database. But the problem is, every time i click add row it adds a row but changes the values that i have changed previously in "<select>" menu to default values i.e it erases the values i have entered and add a new row with default values. What i want is to append a row with keeping the changed values as it is. Here is the code i have written..
Please any one help me..
Code: Select all
[/b]
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html><head><title>New Order</title>
<meta http-equiv=content-type content="text/html; charset=utf-8">
<link href="style.css" type=text/css rel=stylesheet>
<meta content="mshtml 6.00.2900.2180" name=generator>
<script language="JavaScript" type="text/JavaScript">
var new_row;
function read()
{
new_row = document.getElementById("add").innerHTML;
}
function ajaxFunction()
{
document.getElementById("add").innerHTML = document.getElementById("add").innerHTML+new_row;
}
</script>
</head>
<body onLoad="read();">
<?php include ("includes/connection.php"); ?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center">
<table width="780" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<table width="780" bgcolor="#ffffff" border="0">
<tr>
<td><img src="images/top1.JPG" width="780" height="202" /></td>
</tr>
<tr>
<td><b><center>New Order</center></b></td>
</tr>
<tr>
<td><table width="780" border="0">
<tr>
<td>
<form name="form" action="order1.php" method="POST" >
<table width="640" height="28" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#C6C6C6">
<tr>
[b]<td width="80"><input name="Add_row" type="button" value="Add_row" onClick="ajaxFunction()"></td>[/b]
</tr>
</table>
<div id="add">
<table width="640" border="1" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="63"><div align="center">
<select name="density[]" id="density" >
<?php
$query2 = "SELECT * FROM DENSITY";
$result2 = mysql_query($query2);
while ($line2 = mysql_fetch_array($result2)) {
?>
<option value="<?php echo $line2["density"] ?>"><?php echo $line2["density"] ?></option>
<?php
}
?>
</select>
</div></td>
<td width="98"><div align="center">
<select name="size[]" id="size">
<?php
$query3 = "SELECT * FROM SIZE";
$result3 = mysql_query($query3);
while ($line3 = mysql_fetch_array($result3)) {
?>
<option value="<?php echo $line3["si_len"] ?>"><?php echo $line3["si_len"] ?>x<?php echo $line3["si_bred"] ?></option>
<?php
}
?>
</select>
</div></td>
<td width="68"><div align="left">
<select name="th_id[]" id="thick">
<?php
$query4 = "SELECT * FROM THICK";
$result4 = mysql_query($query4);
while ($line4 = mysql_fetch_array($result4)) {
?>
<option value="<?php echo $line4["th_id"] ?>"><?php echo $line4["thick"] ?></option>
<?php
}
?>
</select>
</div></td>
<td width="78"><div align="center">
<input name="no_of_bun[]" type="text" size="5">
</div></td>
<td width="75"><div align="center">
<select name="grade[]" id="grade">
<?php
$query5 = "SELECT * FROM GRADE";
$result5 = mysql_query($query5);
while ($line5 = mysql_fetch_array($result5)) {
?>
<option value="<?php echo $line5["grade"] ?>"><?php echo $line5["grade"] ?></option>
<?php
}
?>
</select>
</div></td>
<td width="81" style="border:#FFFFFF"></td>
</tr>
</table>
</div>
<p align="center"><input name="submit" type="submit" value="Submit" ></p>
</form> </td>
</tr>
</table></td>
</tr>
<tr>
<td><img src="images/bottom.jpg" width="780"></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body></html>
[b][/b]