Hi, i'm quite new with PHP, i'm trying to modify some code, what I want to do is to get the value that is calculated via php and use it on an html input text field, hr_extra, wich I wrote here in yellow color, so the user could be able to modify it, I want it to get the $totalAmount variable, but I haven't been able to parse it.
here's the code from ordercheckout.php
Code:
<?php
session_start();
require_once("shared.php");
//XAJAX HANDLERS
require_once("xajax_core/xajax.inc.php");
$xajax = new xajax();
$xajax->register(XAJAX_FUNCTION, "xsetImage");
function xsetImage($value, $id)
{
$objResponse = new xajaxResponse();
if(!isset($_SESSION['images']))
{
$_SESSION['images'] = array();
}
if($value == 1)
{
$_SESSION['images'][] = $id;
}
else
{
for($i=0;$i<count($_SESSION['images']);$i++)
{
if($_SESSION['images'][$i] == $id)
{
$_SESSION['images'][$i] = 0;
break;
}
}
}
return $objResponse;
}
$xajax->processRequest();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script>
function viewPdf()
{
document.getElementById('order-checkout').action = 'viewpdf.php';
document.getElementById('order-checkout').target = '_new';
document.getElementById('order-checkout').submit();
}
function sendPdf()
{
document.getElementById('order-checkout').action = 'ordersend.php';
document.getElementById('order-checkout').target = '_self';
document.getElementById('order-checkout').submit();
}
</script>
<?php $xajax->printJavascript(); ?>
<link rel="stylesheet" href="stylesheets/style.css" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Nox - Checkout de Orden</title>
</head>
<body>
<div id="debugger"></div>
<div id="wrapper">
<form id="order-checkout" action="ordersend.php" method="post">
<fieldset>
<legend>Resumen de Cotizacion</legend>
<div class="inputEntry">
<label class="labelL">Nombre del Cliente</label>
<label><?php echo $_SESSION['c-name']; ?></label>
</div>
<div class="inputEntry">
<label class="labelL">Direccion</label>
<label><?php echo $_SESSION['c-address']; ?></label>
</div>
<div class="inputEntry">
<label class="labelS">Telefono</label>
<label><?php echo $_SESSION['c-phone']; ?></label>
</div>
<div class="inputEntry">
<label class="labelS">Email</label>
<label><?php echo $_SESSION['c-email']; ?></label>
</div>
<div class="inputEntry">
<label class="labelS">Fecha de Nacimiento</label>
<label><?php echo $_SESSION['c-dob']; ?></label>
</div>
<div class="inputEntry">
<label class="labelS">Horas de Servicio</label>
<input type="text" id="hours" name="hours" style="width:60px;"class="inputTextL required" value="5"/>
</div>
<div class="inputEntry">
<label class="labelS">Cotizacion desglosada</label>
<input type="checkbox" name="des" id="des"/>
</div>
<div class="inputEntry">
<label class="labelS">Destinatarios</label>
<input type="text" name="dest" style="width:600px;"
class="inputTextL required" value="<?php echo $_SESSION['c-email']; ?>"/>
<div class="inputEntry">
<label class="labelS">Hr. Extra</label>
<input type="text" id="hr_extra" name="hr_extra" style="width:100px;" value=""/>
</div>
</div>
<div class="order-actions">
<ul>
<li><input type="button" value="Modificar Cliente" class="submit"
onclick="document.location='clientregistry.php'"/></li>
<li><input type="button" value="Modificar Orden" class="submit"
onclick="document.location='productcatalog.php'"/></li>
<li><input type="button" value="Visualizar PDF" class="submit"
onclick="viewPdf()"/></li>
<li><input type="button" value="Finalizar y Enviar" class="submit"
onclick="sendPdf()"/></li>
</ul>
</div>
<div id="product-summary">
<div id="p-details">
<div>Concepto</div>
<div>Cantidad</div>
<div>Precio Unitario</div>
<div>Subtotal</div>
</div>
<div id="order-content">
<?php
$totalAmount = 0;
//Print current Items
for($i=0;$i<count($_SESSION['productIDS']);$i++)
{
if($_SESSION['productQuantities'][$i] < 1)
continue;
$product = getProductById($_SESSION['productIDS'][$i]);
$subTotal = $product->price * $_SESSION['productQuantities'][$i];
$totalAmount += $subTotal;
$html .= '
<div id="p-content">
<div>'.$product->name.'</div>
<div>'.$_SESSION['productQuantities'][$i].'</div>
<div>$'.number_format($product->price, 2).'</div>
<div>$'.number_format($subTotal, 2).'</div>
</div>
';
}
echo $html;
//MANDAR TOTAL
if($_SESSION['dsc'] > 0)
{
$html = '
<div id="p-content">
<div> </div>
<div> </div>
<div style="font-weight:bold;">Descuento</div>
<div style="font-weight:bold;">'.number_format($_SESSION['dsc'], 2).'%</div>
</div>
';
$totalAmount = $totalAmount - ($totalAmount * ($_SESSION['dsc']/100));
echo $html;
}
$html= '
<div id="p-content">
<div> </div>
<div> </div>
<div style="font-weight:bold;">Total:</div>
<div style="font-weight:bold;">$'.number_format($totalAmount, 2).'</div>
</div>
';
//echo $totalAmount;
echo $html;
?>
</div>
</div>
<div>
<label>Imagenes para adjuntar</label>
<ul id="image-list">
<?php
for($i=0;$i<count($_SESSION['productIDS']);$i++)
{
$html = "";
if($_SESSION['productQuantities'][$i] > 0)
{
$image = getImageByProductId($_SESSION['productIDS'][$i]);
if(!empty($image))
{
$html .= '<li><input type="checkbox" name="images[]" value="'.$image->id.'" /><img src="images/'.$image->url.'" width="150px"/></li>';
}
}
echo $html;
}
?>
</ul>
</div>
</fieldset>
</form>
</div>
</body>
</html>