Need some javascript/php/sql help please


#1

Firstly, hi all, and i apologise i am very new to this!

I have a fully functional SQL read php page with a few functions.

My issue is i need pass javascript functions adultticketqty, concessionticketqty, studentticketqty, childticketqty, programticketqty and total sell through to PHP in order to write to SQL table.

My insert.php code will write static values, but i can’t get the javascript values to pass through.

Ive spent a number of hours without success trying to get it working, so any assistance would be greatly appreciated.

Cheers

i have the following html code

<!doctype html>
<html>
<script type="text/javascript" src="//code.jquery.com/jquery-2.1.0.min.js"></script>
<head>
<meta charset="utf-8">
<title>Hobart &amp; Latrobe Raceway POS Terminal</title>
<style type="text/css">
body {
	background-color: #000000;
	text-align: center;
	font-size: 24px;
	font-family: Impact, Haettenschweiler, "Franklin Gothic Bold", "Arial Black", sans-serif;
	font-style: normal;
	font-weight: 400;
	color: #272727
}
	.quantity {
		background-color: #000000;
	text-align: center;
	font-size: 60px;
	font-family: Impact, Haettenschweiler, "Franklin Gothic Bold", "Arial Black", sans-serif;
	font-style: normal;
	font-weight: 500;
	color: white
	}
	
	.totalquantities {
		background-color: #FF0000;
	text-align: center;
	font-size: 20px;
	font-family: Impact, Haettenschweiler, "Franklin Gothic Bold", "Arial Black", sans-serif;
	font-style: normal;
	font-weight: 200;
	color: white
	}
	
	.lineprice {
		background-color: #000000;
	text-align: center;
	font-size: 40px;
	font-family: Impact, Haettenschweiler, "Franklin Gothic Bold", "Arial Black", sans-serif;
	font-style: normal;
	font-weight: 400;
	color: white
	}
	
	.totalsell {
		background-color: #FF0000;
	text-align: center;
	font-size: 50px;
	font-family: Impact, Haettenschweiler, "Franklin Gothic Bold", "Arial Black", sans-serif;
	font-style: normal;
	font-weight: 600;
	color: white
	}
	
.display {
	font-family: amaranth;
	font-style: normal;
	font-weight: 400;
	font-size: 60px;
	color: #FFFFFF;
	text-align: center;
}
</style>
<!--The following script tag downloads a font from the Adobe Edge Web Fonts server for use within the web page. We recommend that you do not modify it.-->
<script>var __adobewebfontsappname__="dreamweaver"</script>
<script src="http://use.edgefonts.net/amaranth:n4:default;acme:n4:default;hammersmith-one:n4:default.js" type="text/javascript"></script>

</head>
<?php
	include('phpsqlget.php');
	?>
<body>
<span style="font-family: Impact, Haettenschweiler, 'Franklin Gothic Bold', 'Arial Black', sans-serif"></span>

<script type="text/javascript">

//Set the ticket/program quantities to a default of 0
var adultticketqty = 0;
var concessionticketqty = 0;
var studentticketqty = 0;
var childticketqty = 0;
var programqty = 0;
var adultlineprice = 0;
var	concessionlineprice = 0;
var studentlineprice = 0;
var childlineprice = 0;
var	programlineprice = 0;
var totalsaleprice = 0;
var totaltickets = 0;

	
//Adult Ticket Calculations
function adultticketadd(){
     adultticketqty++;
     document.getElementById('displayadultqty').innerHTML = adultticketqty;
}
function adultticketsubtract(){
     adultticketqty--;
     document.getElementById('displayadultqty').innerHTML = adultticketqty;
}

	
function calculateadultTotal()
{
    //display the result
	adultlineprice = <?php echo($AdultPrice); ?> * adultticketqty
    var divobj = document.getElementById('adultlinesell');
    divobj.style.display='block';
    divobj.innerHTML = "$"+adultlineprice;
}

//Concession Ticket Calculations
function concessionticketadd(){
     concessionticketqty++;
     document.getElementById('displayconcessionqty').innerHTML = concessionticketqty;
}

function concessionticketsubtract(){
     concessionticketqty--;
     document.getElementById('displayconcessionqty').innerHTML = concessionticketqty;
}

		function calculateconcessionTotal()
{
    //display the result
	concessionlineprice = <?php echo($ConcessionPrice); ?> * concessionticketqty	
    var divobj = document.getElementById('concessionlinesell');
    divobj.style.display='block';
    divobj.innerHTML = "$"+concessionlineprice;
}

// Student Ticket Calculations

function studentticketadd(){
     studentticketqty++;
     document.getElementById('displaystudentqty').innerHTML = studentticketqty;
}
function studentticketsubtract(){
     studentticketqty--;
     document.getElementById('displaystudentqty').innerHTML = studentticketqty;
}
	
function calculatestudentTotal()
{

    //display the result
	studentlineprice = <?php echo($StudentPrice); ?> * studentticketqty
    var divobj = document.getElementById('studentlinesell');
    divobj.style.display='block';
    divobj.innerHTML = "$"+studentlineprice;
}

// Child Ticket Calculations
function childticketadd(){
     childticketqty++;
     document.getElementById('displaychildqty').innerHTML = childticketqty;
}
function childticketsubtract(){
     childticketqty--;
     document.getElementById('displaychildqty').innerHTML = childticketqty;
}
	
function calculatechildTotal()
{
    //display the result
	childlineprice = <?php echo($ChildPrice); ?> * childticketqty
    var divobj = document.getElementById('childlinesell');
    divobj.style.display='block';
    divobj.innerHTML = "$"+childlineprice;
}

//Program Calculations
	
function programadd(){
     programqty++;
     document.getElementById('displayprogramqty').innerHTML = programqty;
}
function programsubtract(){
     programqty--;
     document.getElementById('displayprogramqty').innerHTML = programqty;
}
	
	function calculateprogramTotal()
{
    //display the result
	programlineprice = <?php echo($ProgramPrice); ?> * programqty
    var divobj = document.getElementById('programlinesell');
    divobj.style.display='block';
    divobj.innerHTML = "$"+programlineprice;
}

//calculate total sale price
function calcsellprice()
{
    //display the result
	totalsaleprice = adultlineprice + concessionlineprice + studentlineprice + childlineprice + programlineprice
    var divobj = document.getElementById('totalsalesell');
    divobj.style.display='block';
    divobj.innerHTML = "$"+totalsaleprice;+":00"
}
	
	//calculate total number of tickets
function calctotaltickets()
{
    //display the result
	totaltickets = adultticketqty + concessionticketqty + studentticketqty + childticketqty
    var divobj = document.getElementById('totalticketitemqty');
    divobj.style.display='block';
    divobj.innerHTML = totaltickets;
	
	
}
//calculate total number programs
function calctotalprograms()
{
	var divobj = document.getElementById('totalprogramitemqty');
    divobj.style.display='block';
    divobj.innerHTML = programqty;
}
	
	

  function passVal(){
        var data = {
            fn: "filename",
            str: "this_is_a_dummy_test_string"
        };

        $.post("test.php", data);
    }
    passVal();
</script></script>
	
<table width="1016" height="524" border="0" cellpadding="0" cellspacing="0">
<tbody>
  </tbody>
<tbody>
  <tr>
    <td width="177" height="50" rowspan="2" style="text-align: center"><img src="assets/Hobart Raceway - Logo_Transparent" width="141" height="136" alt=""/></td>
    <td width="260" height="50" colspan="4" style="font-size: 60px"><img src="assets/AdultwithoutSign" width="228" height="70" alt="" /></td>
    <td width="80" height="50" colspan="6" style="font-size: 60px"><img  src="assets/+" alt="" width="70" height="70" class="AdultTicketAddImage" onClick="adultticketadd();calculateadultTotal();calcsellprice();calctotaltickets();calctotalprograms();"/></td>
    <td width="80" height="50" style="font-size: 60px"><img src="assets/-" alt="" width="70" height="70" class="AdultTicketSubtractImage" onClick="adultticketsubtract();calculateadultTotal();calcsellprice();calctotaltickets();calctotalprograms();"/></td>
    <th width="131" height="50" nowrap bgcolor="#5E4D4E" class="display" style="color: #FFFFFF"><div class="quantity" id="displayadultqty">
      <script type="text/javascript">document.write(adultticketqty);</script>
    </div></th>
    <td width="87" height="50" style="color: #FFFFFF">&nbsp;</td>
    <td width="171" height="50" class="AdultLineSell" style="font-size: 36px"><div class="lineprice" id="adultlinesell"></div></td>
  </tr>
  <tr>
    <td height="50" colspan="4" valign="middle"><img src="assets/ConcessionwithoutSign" width="228" height="70" alt=""/></td>
    <td height="50" colspan="6" valign="middle"><img src="assets/+" alt="" width="70" height="70" class="ConcessionTicketAddImage" onClick="concessionticketadd();calculateconcessionTotal();calcsellprice();calctotaltickets();calctotalprograms();"/></td>
    <td height="50" valign="middle"><img src="assets/-" alt="" width="70" height="70" class="ConcessionTicketSubtractImage" onClick="concessionticketsubtract();calculateconcessionTotal();calcsellprice();calctotaltickets();calctotalprograms();"/></td>
    <td height="50" valign="middle" bgcolor="#5E4D4E" class="ConcessionTicketQty" style="color: #FFFFFF"><div class="quantity" id="displayconcessionqty">
      <script type="text/javascript">document.write(concessionticketqty);</script>
    </div></td>
    <td height="50" valign="middle" style="color: #FFFFFF">&nbsp;</td>
    <td height="50" valign="middle" class="ConcessionTicketLineSell" style="font-size: 36px"><div class="lineprice" id="concessionlinesell"></div></td>
  </tr>
  <tr>
    <td height="50" style="text-align: center"><img src="assets/SOLO Logo_Transparent" width="113" height="59" alt=""/></td>
    <td height="50" colspan="4" style="font-size: 60px"><img src="assets/StudentwithoutSign" width="228" height="70" alt=""/></td>
    <td height="50" colspan="6" style="font-size: 60px"><img src="assets/+" width="70" height="70" alt=""  class="StudentTicketAddImage" onClick="studentticketadd();calculatestudentTotal();calcsellprice();calctotaltickets();calctotalprograms();"/></td>
    <td height="50" style="font-size: 60px"><img src="assets/-" width="70" height="70" alt=""  class="StudentTicketSubtractImage" onClick="studentticketsubtract();calculatestudentTotal();calcsellprice();calctotaltickets();calctotalprograms();"/></td>
    <td height="50" bgcolor="#5E4D4E" class="StudentTicketQty" style="color: #FFFFFF"><div class="quantity" id="displaystudentqty">
      <script type="text/javascript">document.write(studentticketqty);</script>
    </div></td>
    <td height="50" style="color: #FFFFFF">&nbsp;</td>
    <td height="50" class="StudentTicketLineSell" style="font-size: 36px"><div class="lineprice" id="studentlinesell"></div></td>
  </tr>
  <tr>
    <td height="50" valign="middle" style="text-align: center"><img src="assets/Schweppes-logo" width="104" height="50" alt=""/></td>
    <td height="50" colspan="4" valign="middle" style="font-size: 60px"><img src="assets/ChildwithoutSign" width="228" height="70" alt=""/></td>
    <td height="50" colspan="6" valign="middle" style="font-size: 60px"><img src="assets/+" width="70" height="70" alt="" class="ChildTicketAddImage" onClick="childticketadd();calculatechildTotal();calcsellprice();calctotaltickets();calctotalprograms();"/></td>
    <td height="50" valign="middle" style="font-size: 60px"><img src="assets/-" width="70" height="70" alt=""  class="ChildTicketsubtractImage" onClick="childticketsubtract();calculatechildTotal();calcsellprice();calctotaltickets();calctotalprograms();"/></td>
    <td height="50" valign="middle" bgcolor="#5E4D4E" class="childticketqty" style="color: #FFFFFF"><div class="quantity" id="displaychildqty">
      <script type="text/javascript">document.write(childticketqty);</script>
    </div></td>
    <td height="50" valign="middle" style="color: #FFFFFF">&nbsp;</td>
    <td height="50" valign="middle" style="font-size: 36px"><div class="lineprice" id="childlinesell"></div></td>
  </tr>
  <tr>
    <td height="50">&nbsp;</td>
    <td height="50" colspan="4" style="font-size: 60px"><img src="assets/ProgramwithoutSign" width="228" height="70" alt=""/></td>
    <td height="50" colspan="6" style="font-size: 60px"><img src="assets/+" width="70" height="70" alt=""  class="ProgramAddImage" onClick="programadd();calculateprogramTotal();calcsellprice();calctotaltickets();calctotalprograms();"/></td>
    <td height="50" style="font-size: 60px"><img src="assets/-" width="70" height="70" alt=""  class="ProgramSubtractImage" onClick="programsubtract();calculateprogramTotal();calcsellprice();calctotaltickets();calctotalprograms();"/></td>
    <td height="50" bgcolor="#5E4D4E" class="ProgramTicketQty" style="color: #FFFFFF"><div class="quantity" id="displayprogramqty">
      <script type="text/javascript">document.write(programqty);</script>
    </div></td>
    <td height="50" style="color: #FFFFFF">&nbsp;</td>
    <td height="50" style="font-size: 36px"><div class="lineprice" id="programlinesell"></div></td>
  </tr>
  
  <tr>
    <td height="3" colspan="4" nowrap="nowrap" style="font-size: 9px" ">&nbsp;</td>
    <td height="3" colspan="8" nowrap="nowrap" style="font-size: 9px" ">&nbsp;</td>
    <td height="3" colspan="3" nowrap="nowrap" style="font-size: 9px" ">&nbsp;</td>
  </tr>
  <tr>
    <td height="30" colspan="4" class="totalquantities" ">TOTAL TICKETS:</td>
    <td height="30" colspan="8" class="totalquantities" ">TOTAL PROGRAMS:</td>
    <td height="30" colspan="3" class="totalquantities"">SALE TOTAL:</td>
  </tr>
  <tr>
    <td height="63" colspan="4" bgcolor="#FF0004" style="color: #FFFFFF"><div class "totalquantities" id="totalticketitemqty"></div></td>
    <td colspan="8" bgcolor="#FF0004" style="color: #FFFFFF"><div class "totalquantities" id="totalprogramitemqty"></div></td>
    <td colspan="3" bgcolor="#FF0004" style="font-size: 45px"><div class="totalsell" id="totalsalesell"></div></td>
  </tr>
  </tbody>
<tbody>
</tbody>
</table>
<table width="1016" border="0" cellpadding="0" cellspacing="0">
  <tbody>
    <tr>
      <td height="5">&nbsp;</td>
      <td height="5">&nbsp;</td>
      <td height="5" style="color: #555252">&nbsp;</td>
      <td height="5" colspan="2">&nbsp;</td>
      <td height="5">&nbsp;</td>
    </tr>
    <tr>
      <td width="228"><img src="assets/VoidSale" width="228" height="70" alt=""/></td>
      <td width="44">&nbsp;</td>
      <td width="228" style="color: #555252"><img src="assets/DriverEntry" width="228" height="70" alt=""/></td>
      <td width="228" style="color: #555252"><img src="assets/ScanEntry" width="228" height="70" alt=""/></td>
      <td width="56" style="color: #000000">&nbsp;</td>
      <td width="232"><form action="insert.php" method="post">
    <input type="image" src="assets/CompleteSale" alt="Submit">
</form></td>
    </tr>
  </tbody>
</table>
<p>&nbsp;</p>
</body>
</html>

insert.php contains

<?php
	


include('phpsqlget.php');
$adultticketqty = "<script>document.write(adultticketqty);</script>";
//echo $adultticketqty;	
/* Attempt MySQL server connection. Assuming you are running MySQL
server with default setting (user 'root' with no password) */
$link = mysqli_connect("localhost", "root", "speedway", "speedwayticketsales");
 
// Check connection
if($link === false){
    die("ERROR: Could not connect. " . mysqli_connect_error());
}
 
// Attempt insert query execution
$sql = "INSERT INTO stdsalesrecords (qtyadulttickets, qtyconcessiontickets, qtystudenttickets, qtychildtickets, qtyprograms, totalsell) VALUES ($adultticketqty, '4', '0', '2', '1', '212')";
if(mysqli_query($link, $sql)){
    echo "Records inserted successfully.";
} else{
    echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
 
// Close connection
mysqli_close($link);
?>

phpsqlget.php contains

<?php
	

$db = new PDO('mysql:host=localhost;dbname=speedwayticketsales', 'root', 'speedway');
	
// Lookup Adult Ticket price from SQL Table
$sql = "SELECT ticketprice FROM stdevent_prices WHERE tickettype = 'Adult'";
$select = $db->prepare($sql);
$select->bindParam('Adult', $Adult, PDO::PARAM_INT);
$select->execute();

$AdultPriceSQL = $select->fetch(PDO::FETCH_ASSOC);

$AdultPrice = $AdultPriceSQL['ticketprice'];

// Lookup Concession Ticket price from SQL Table
$sql = "SELECT ticketprice FROM stdevent_prices WHERE tickettype = 'Concession'";
$select = $db->prepare($sql);
$select->bindParam('Concession', $Concession, PDO::PARAM_INT);
$select->execute();

$ConcessionPriceSQL = $select->fetch(PDO::FETCH_ASSOC);

$ConcessionPrice = $ConcessionPriceSQL['ticketprice'];
 
// Lookup Student Ticket price from SQL Table
$sql = "SELECT ticketprice FROM stdevent_prices WHERE tickettype = 'Student'";
$select = $db->prepare($sql);
$select->bindParam('Student', $Student, PDO::PARAM_INT);
$select->execute();

$StudentPriceSQL = $select->fetch(PDO::FETCH_ASSOC);

$StudentPrice = $StudentPriceSQL['ticketprice'];

// Lookup Child Ticket price from SQL Table
$sql = "SELECT ticketprice FROM stdevent_prices WHERE tickettype = 'Child'";
$select = $db->prepare($sql);
$select->bindParam('Child', $Child, PDO::PARAM_INT);
$select->execute();

$ChildPriceSQL = $select->fetch(PDO::FETCH_ASSOC);

$ChildPrice = $ChildPriceSQL['ticketprice'];

// Lookup program price from SQL Table
$sql = "SELECT ticketprice FROM stdevent_prices WHERE tickettype = 'Program'";
$select = $db->prepare($sql);
$select->bindParam('Program', $Program, PDO::PARAM_INT);
$select->execute();

$ProgramPriceSQL = $select->fetch(PDO::FETCH_ASSOC);

$ProgramPrice = $ProgramPriceSQL['ticketprice'];

?>

#2

Just scanning, and trying to get the general gist. We don’t see any jQuery code so you may as well either drop that import (which should be in the HEAD, btw) or exploit the library in your source to simplify the code.

Of note, though I’m sure one knows this, JavaScript cannot be used to generate a response document. PHP is pre-processed HTML on the server-side, where JS is on the client-side.

To pass data to the server either a form element or an XHR will be required.


#3

Hi,

Thanks for the reply.

I’ve been playing, hence probably why the jQuery is in the code, and in the incorrect position.

I have attempted to pass through the javascript through a form action element without any success.

If i have a javascript variable ‘adultticketqty’ how would i pass this through an onclick image?


#4

The form needs to have named input fields to hold the post data that is passed to the handler (insert.php). The fields can be populated dynamically through their value attribute. That’s one way.

Another way would be to pass a query string with the action URL.

insert.php?var1=something&var2=somethingelse&...

Build the query string dynamically to contain the data you wish to pass to the handler. If this approach is used, you do not need a form.


#5

awesome i like the idea of passing through an action url

Would it be an issue if i was to pass through multiple (say up to 8-10) variables through this method? or would it be better to go back to the form method?

Also do you have any live examples i could base my code on?

Thanks!


#6

There is no limit on how many variables are passed in a query string but it could be unwieldly if you pass too many. The handler will need to parse the URL to build an associative array of the query parts. It will be simpler if the variable names are all short. Can’t state with any certainty, but I believe the query string approach is more secure than form post. Seek more opinions on this matter.

Search for parse query string php, or some search phrase to find examples.


#7

Thanks, im still lost. But ill keep trying…


#8

Okay i have some AJAX code, which inserts the data into the SQL table, however gives me an “undefined index” error.

I’ve read the workarounds of this by using the PHP isset, and attempted these, no luck.

When i use the below i get the undefined index error for that line

$adultticketqty = $_POST[‘adultqty’];

When i change it to be the below, i get zero values passed through.

if (isset($_POST[“adultqty”]))
{
$adultticketqty = $_POST[“adultqty”];
echo $adultticketqty;
}
else
{
$adultticketqty = null;
}

Seems to me as if the AJAX code isn’t passing the values through?

My AJAX code:

$( document ).ready(function() {

        $( "#submit" ).submit(function( event ) {

            // Jquery code for making AJAX call to server side script
            $.ajax({
                method: "POST",
                url: "insert.php", // use your server side PHP script file name at here
                data: { adultqty: adultticketqty, concessionqty: concessionticketqty, studentqty: studentticketqty, childqty: childticketqty, programqty: programqty, totalsell: totalsaleprice }
            })
           //alert(adultqty + childqty)
        });

my form:

my insert.php

<?php $adultticketqty = $_POST['adultqty']; $concessionticketqty = $_POST['concessionqty']; $studentticketqty = $_POST['studentqty']; $childticketqty = $_POST['childqty']; $programqty = $_POST['programqty']; $totalsaleprice = $_POST['totalsell']; include('phpsqlget.php'); /* Attempt MySQL server connection. Assuming you are running MySQL server with default setting (user 'root' with no password) */ $link = mysqli_connect("localhost", "root", "speedway", "speedwayticketsales"); // Check connection if($link === false){ die("ERROR: Could not connect. " . mysqli_connect_error()); } // Attempt insert query execution $sql = "INSERT INTO stdsalesrecords (qtyadulttickets, qtyconcessiontickets, qtystudenttickets, qtychildtickets, qtyprograms, totalsell) VALUES ($adultticketqty,$concessionticketqty,$studentticketqty,$childticketqty,$programqty,$totalsaleprice)"; if(mysqli_query($link, $sql)){ echo "Records inserted successfully."; } else{ echo "ERROR: Could not able to execute $sql. " . mysqli_error($link); } // Close connection mysqli_close($link); ?>

oh and my javascript variables are defined here, functions called on image clicks.

//Set the ticket/program quantities to a default of 0 var adultticketqty = 0; var concessionticketqty = 0; var studentticketqty = 0; var childticketqty = 0; var programqty = 0; var adultlineprice = 0; var concessionlineprice = 0; var studentlineprice = 0; var childlineprice = 0; var programlineprice = 0; var totalsaleprice = 0; var totaltickets = 0; //Adult Ticket Calculations function adultticketadd(){ adultticketqty++; document.getElementById('displayadultqty').innerHTML = adultticketqty; } function adultticketsubtract(){ adultticketqty--; document.getElementById('displayadultqty').innerHTML = adultticketqty; } function calculateadultTotal() { //display the result adultlineprice = <?php echo($AdultPrice); ?> * adultticketqty var divobj = document.getElementById('adultlinesell'); divobj.style.display='block'; divobj.innerHTML = "$"+adultlineprice; } //display the result adultlineprice = <?php echo($AdultPrice); ?> * adultticketqty var divobj = document.getElementById('adultlinesell'); divobj.style.display='block'; divobj.innerHTML = "$"+adultlineprice; } //Concession Ticket Calculations function concessionticketadd(){ concessionticketqty++; document.getElementById('displayconcessionqty').innerHTML = concessionticketqty; } function concessionticketsubtract(){ concessionticketqty--; document.getElementById('displayconcessionqty').innerHTML = concessionticketqty; } function calculateconcessionTotal() { //display the result concessionlineprice = <?php echo($ConcessionPrice); ?> * concessionticketqty var divobj = document.getElementById('concessionlinesell'); divobj.style.display='block'; divobj.innerHTML = "$"+concessionlineprice; } // Student Ticket Calculations function studentticketadd(){ studentticketqty++; document.getElementById('displaystudentqty').innerHTML = studentticketqty; } function studentticketsubtract(){ studentticketqty--; document.getElementById('displaystudentqty').innerHTML = studentticketqty; } function calculatestudentTotal() { //display the result studentlineprice = <?php echo($StudentPrice); ?> * studentticketqty var divobj = document.getElementById('studentlinesell'); divobj.style.display='block'; divobj.innerHTML = "$"+studentlineprice; } // Child Ticket Calculations function childticketadd(){ childticketqty++; document.getElementById('displaychildqty').innerHTML = childticketqty; } function childticketsubtract(){ childticketqty--; document.getElementById('displaychildqty').innerHTML = childticketqty; } function calculatechildTotal() { //display the result childlineprice = <?php echo($ChildPrice); ?> * childticketqty var divobj = document.getElementById('childlinesell'); divobj.style.display='block'; divobj.innerHTML = "$"+childlineprice; } //Program Calculations function programadd(){ programqty++; document.getElementById('displayprogramqty').innerHTML = programqty; } function programsubtract(){ programqty--; document.getElementById('displayprogramqty').innerHTML = programqty; } function calculateprogramTotal() { //display the result programlineprice = <?php echo($ProgramPrice); ?> * programqty var divobj = document.getElementById('programlinesell'); divobj.style.display='block'; divobj.innerHTML = "$"+programlineprice; } //calculate total sale price function calcsellprice() { //display the result totalsaleprice = adultlineprice + concessionlineprice + studentlineprice + childlineprice + programlineprice var divobj = document.getElementById('totalsalesell'); divobj.style.display='block'; divobj.innerHTML = "$"+totalsaleprice;+":00" } //calculate total number of tickets function calctotaltickets() { //display the result totaltickets = adultticketqty + concessionticketqty + studentticketqty + childticketqty var divobj = document.getElementById('totalticketitemqty'); divobj.style.display='block'; divobj.innerHTML = totaltickets; } //calculate total number programs function calctotalprograms() { var divobj = document.getElementById('totalprogramitemqty'); divobj.style.display='block'; divobj.innerHTML = programqty;

#9

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.