- Joined
- Dec 4, 2007
- Messages
- 1,936
- Reaction score
- 96
I would like in the Total (US Dollars) box to have a variable $totalcost, but need it to update live based on the Select Gold Quantity input. I've never used Javascript/Ajax/whatever I need before, so any help is appreciated.
theme/orderform.html.php:
includes/orderform.php
theme/orderform.html.php:
PHP:
<div class="mainimage"><br />
<div class="ordergold">
<div class="orderform">
<div class="tablehead">
Secure Order Form
</div>
<form action="includes/orderform.php" method="post" enctype="multipart/form-data">
<div class="goldquantity">
Select Gold Quantity (Millions)<br />
<input type="text" class="forminput" name="goldquantity" value="0" required="required">
</div>
<div class="totalcost">
Total (US Dollars)<br />
<div class="formnoninput" id="Update">$ 0</div>
</div>
<div class="displayname">
Display Name<br />
<input type="text" class="forminput" name="displayname" value="" required="required">
</div>
<div class="paymentmethod">
Payment Method<br />
<div class="formnoninput">Paypal</div>
</div>
<div class="clear">
</div>
<input class="continue" type="submit" value="" />
</form>
</div>
</div>
</div>
includes/orderform.php
PHP:
<?php
include('config.php');
include('functions.php');
$goldquantity = $_POST['goldquantity'];
$pricemil = 0.35;
$totalcost = $goldquantity * $pricemil;
$displayname = $_POST['displayname'];
$invoiceid = time();
$ipaddress = $_SERVER['REMOTE_ADDR'];
mysql_query("INSERT INTO orders(`goldquantity`, `totalcost`, `displayname`, `paymentmethod`, `invoiceid`, `ipaddress`, `complete`) VALUES('" . $goldquantity . "', '" . $totalcost . "', '" . $displayname . "', 'Paypal', '" . $invoiceid . "', '" . $ipaddress . "', '0')") or die(mysql_error());
echo '<meta http-equiv="REFRESH" content="0;url=../loginform.php?invoiceid=' . $invoiceid . '">';
?>