Can someone help please i have a code and want the quantity to be retrieved from the database and loaded to each textfield row.can someone help debug. thanks.
<SCRIPT LANGUAGE="JavaScript">
function getValues(objName,objName2,objName3)
{
var var3 = "";
var arr = new Array();
arr = document.getElementsByName(objName);
arr2 = document.getElementsByName(objName2);
arr3 = document.getElementsByName(objName3);
for(var i = 0; i < arr.length; i++)
{
for(var i = 0; i < arr2.length; i++)
{
for(var i = 0; i < arr3.length; i++)
{
var obj1 = document.getElementsByName(objName2).item(i);
var var2 = obj1.value;
var obj = document.getElementsByName(objName).item(i);
var var1 = obj.value;
var obj3 = document.getElementsByName(objName3).item(i);
var var3 = obj3.value;
var var4 = var1 * var2;
document.getElementsByName(objName3).item(i).value=var4;
}
}
}
}
</script>
<table id="dataTable" width="597" border="0">
<tr>
<td width="20"><input name="s_no[]" readonly="readonly" type="text" value="1" size="2"/></td>
<td width="114"><select name="product[]" id="product[]">
<option selected="selected">-- Select Product --</option>
<?php $sql1=mysql_query("SELECT * FROM products");
while($fet=mysql_fetch_array($sql1)){
$productname=$fet['productname'];
//$uname=$fet['uname'];
echo "<option value='$productname'> $productname </option>";
}?>
</select></td>
<td width="144"><input name="qty[]" type="text" size="10"/></td>
<td width="144"><input name="unitprice[]" type="text" onblur="getValues('qty[]','unitprice[]','amount[]')" onmouseout="getValues('qty[]','unitprice[]','amount[]')" size="10"/></td>
<td width="153"><input name="amount[]" type="text" onblur="getValues('qty[]','unitprice[]','amount[]')" onclick="getValues('qty[]','unitprice[]','amount[]')" size="15"/></td>
</tr>
</table>
<input type="button" value="Add Row" onclick="addRow('dataTable')" />
<input type="button" value="Delete Row" onclick="deleteRow('dataTable')" /></td>
<tr>
<td height="24"><input type="submit" name="submit" value="Submit" />
<input type="reset" name="Submit2" value="Cancel" /></td>
</tr>