Hi all, I still have this one problem with getting an automated calculation in Jscript and displaying and writing it to database. If anyone could please help it'll be greatly apprciated.
Thanks
heres the jscript code:
<!--
function IsItReady(form)
{
if (form.stock_unitprice!="" and form.stock_markup !="")
{
form.stock_ourprice.value=calc(form.stock_unitprice.value*form.stock_markup.value);
}
}
//-->
And heres the php code
<td class="header"><div align="center"><strong>R</strong>
<input type="text" name="stock_unitprice" id="stock_unitprice" >
</div></td>
<td class="header"><div align="center">
<input type="text" name="stock_markup" id="stock_markup" onChange="IsItReady(stockForm)">
<strong>%</strong></div></td>
<td class="header"><div align="center">
<strong>R</strong>
<input name="stock_ourprice" type="text" size="15" id="stock_ourprice">
</div></td>
And heres the database part.
if (isset($POST['form_complete']))
{
if (isset($POST['stock_code']))
{
$query = "UPDATE stock SET " .
"stock_add = 0, " .
"stock_description = '" . $_POST['stock_description'] . "'," .
"stock_category = '" . $_POST['stock_category'] . "'," .
"stock_type_ID = '" . $_POST['stock_type_ID'] . "', " .
"stock_qty = '" . $_POST['stock_qty'] . "', " .
"stock_serial = '" . $_POST['stock_serial'] . "'," .
"stock_date = NOW(), " .
"stock_unitprice = '" . $_POST['stock_unitprice'] . "'," .
"stock_markup = '" . $_POST['stock_ourprice'] . "'," .
"stock_ourprice = '" . $_POST['stock_ourprice'] . "'" .
"WHERE stock_code = " . $_POST['stock_code'];
if (!$result = mysql_query($query, $link))
die("<p>Cannot save updated stock information!</p><p>" . mysql_error() . "</p><p>" . $query . "</p>");
}
Please please help