Go Back   CodingForums.com > :: Client side development > JavaScript programming > Ajax and Design

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-04-2012, 01:34 AM   PM User | #1
searls03
New Coder

 
Join Date: Jun 2011
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
searls03 is an unknown quantity at this point
Pos

I am trying to build a Point of Sale System. I am not very good at Ajax/javascript, php is okish.

My goal is to make a dynamic page that will have many buttons that will loop through a php code grabing items from database(I have this already). this is a submit button for dynamically created forms, with fields of product and price. I need to know how I could post each of these forms to my database, without a page refresh, then, without a refresh, show the item that was submitted, and any other items that my have previously been submitted(for that session) in an area off to the side. my requirement for this part is that they need to be displayed inside of another form, that I can then update or delete the product, and then the area updates(again, without a refresh). then at the bottom, the total price will display. can anyone help me with this? I hope this makes some sense....
searls03 is offline   Reply With Quote
Old 11-04-2012, 01:37 AM   PM User | #2
searls03
New Coder

 
Join Date: Jun 2011
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
searls03 is an unknown quantity at this point
this is the code that I have:
PHP Code:
<?php
session_start
(); 
require_once 
"connect.php";
 

    
if(isset(
$_SESSION['logged'])){
    
// Query member data from the database and ready it for display

$cid $_SESSION['complete'];  
 
$academy $_SESSION['academy']; 
 if(
$academy=="Old_Cheney"){$city"Lincoln";}else if($academy=="Yankee_Hill"){$city"Lincoln";}else if($academy=="Holdrege"){$city"Lincoln";}else if($academy=="Maple"){$city"Omaha";}
 else if(
$academy=="Center"){$city"Omaha";}
 else if(
$academy=="Pensacola"){$city"Pensacola";}
$sql mysql_query("SELECT * FROM login where academy ='$academy'");
while(
$row mysql_fetch_array($sql)){
$date =$row["date"];
if (
$date !=="".date('m-d-Y')){echo '<meta http-equiv="REFRESH" content="0;url=login.php">';
   exit(); }
   

}
}else{
echo 
'<meta http-equiv="REFRESH" content="0;url=login.php">';
   exit(); 
}
if(
$academy=='all'){echo '<meta http-equiv="REFRESH" content="0;url=dashboard.php">';}


echo 
$cid;

echo 
$academy;
echo 
$city;

?>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>

<script src="SpryAssets/SpryTabbedPanels.js" type="text/javascript"></script><script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script>

<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery.validate/1.7/jquery.validate.min.js"></script>
<script src="SpryAssets/SpryTabbedPanels.js" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function(){
        $(".empty").validate({
            debug: false,
            
            submitHandler: function(form) {
                // do other stuff for a valid form
                $.post('empty.php', $(".empty").serialize(), function(data) {
                $("#total").load("index.php #total");    $("#txtHint").load("index.php #txtHint");
                });
            }
        });
    });
    </script>
   
<?php
// Query member data from the database and ready it for display
$sql mysql_query("SELECT * FROM cart where academy ='$academy' && cart_id = '".$cid."' ");
while(
$row mysql_fetch_array($sql)){
$id =$row["id"];

?>

    <script type="text/javascript">
    $(document).ready(function(){
        $("#delete<?php echo $id?>").validate({
            debug: false,
            
            submitHandler: function(form) {
                // do other stuff for a valid form
                $.post('delete.php', $("#delete<?php echo $id;?>").serialize(), function(data) {
                                    $("#total").load("index.php #total");
    $("#txtHint").load("index.php #txtHint");
                });
            }
        });
    });
    </script>
    <script type="text/javascript">
    $(document).ready(function(){
        $(".delete<?php echo $id2?>").validate({
            debug: false,
            
            submitHandler: function(form) {
                // do other stuff for a valid form
                $.post('delete.php', $(".delete<?php echo $id2;?>").serialize(), function(data) {
                    $("#total").load("index.php #total");$("#txtHint").load("index.php #txtHint");
                    
                });
            }
        });
    });
    </script>
   
    <?php
}
?>
    <?php
// Query member data from the database and ready it for display
$sql mysql_query("SELECT * FROM products");
while(
$row mysql_fetch_array($sql)){
$id =$row["id"];
?>
  <script type="text/javascript">
    $(document).ready(function(){
        $(".myform<?php echo $id?>").validate({
            debug: false,
            
            submitHandler: function(form) {
                // do other stuff for a valid form
                $.post('process.php', $(".myform<?php echo $id;?>").serialize(), function(data) {
                $("#total").load("index.php #total");    $("#txtHint").load("index.php #txtHint");
                });
            }
        });
    });
    </script> 
  

<?php

}
?>
  <script type="text/javascript">
    $(document).ready(function(){
        $("#myfor").validate({
            debug: false,
            
            submitHandler: function(form) {
                // do other stuff for a valid form
                $.post('process.php', $("#myfor").serialize(), function(data) {
                $("#total").load("index.php #total");    $("#txtHint").load("index.php #txtHint");
                });
            }
        });
    });
    </script> 
    


<link rel="stylesheet" href="chosen/chosen.css" />
  <script>
function update_data(){
// set up a point to the iFrame
var ifrm=document.getElementById('frame1');
ifrm.setAttribute('src', 'load_data.php');
document.getElementById('test123').value = document.getElementById('test123').value;
document.getElementById('price_text').value = document.getElementById('price').value;
document.getElementById('total_text').value = document.getElementById('total').value;

// the product_txtbox would be where you want the product to be place on your page, etc.
</script>
    
    <link href="SpryAssets/SpryTabbedPanels.css" rel="stylesheet" type="text/css" />
</head>

<body leftmargin="0">

<div class="container"> <a href="admin.php">Admin Panel</a> | <a href="void.php">Void Sale</a> | <a href="run.php">Balance the Drawer</a>  | <a href="logout.php">Logout</a><br /><form action="check.php" method="POST" name="" class="">
    <input name="cart_id" type="hidden" value="<?php echo $cid?>" /></form>  
  <div id="test123">
</div>

  <div id="container">
    <div class="side-by-side clearfix">
      <div> 
        <script type="text/javascript">
    $(document).ready(function submit(){
        $(".product").validate({
            debug: false,
            
            submitHandler: function(form) {
                // do other stuff for a valid form
                $.post('process1.php', $(".product").serialize(), function(data) {
                    $("#price").load("index.php #price");
                    $("#total").load("index.php #total");
                });
            }
        });
    });
    </script>
 
        

    </div>
  </div>
    

  
  <script src="chosen/chosen.jquery.js" type="text/javascript"></script>
  <script type="text/javascript"> $(".chzn-select").chosen(); $(".chzn-select-deselect").chosen({allow_single_deselect:true}); </script>
  <div id="txtHint"> 
     

    <script type="text/javascript">
function showUser(str)
{
if (str=="")
  {
  document.getElementById("txtHint").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","load_data.php?q="+str,true);
xmlhttp.send();
$("#total").load("index.php #total");
                    $("#txtHint").load("index.php #txtHint");

}
                    

</script>
</head>
    <script type="text/javascript">
    $(document).ready(function(){
        $(".update<?php echo $id 1?>").validate({
            debug: false,
            
            submitHandler: function(form) {
                // do other stuff for a valid form
                $.post('update.php', $(".update<?php echo $id 1;?>").serialize(), function(data) {
                    
                    $("#total").load("index.php #total");
                });
            }
        });
    });
    </script>
    <script type="text/javascript">
function submitForm(str)
{
if (str=="")
  {
  document.getElementById("txtHint").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","delete_data.php?q="+str,true);
xmlhttp.send();
$("#total").load("index.php #total");
                    $("#txtHint").load("index.php #txtHint");

}
                    

</script>
       <script type="text/javascript">
function update(str,dat,dat2,disc)
{
if (str=="")
  {
  document.getElementById("txtHint").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","update.php?q="+str+"&price="+dat2+"&qty="+dat+"&discount="+disc,true);xmlhttp.send();
$("#total").load("index.php #total");
$("#txtHint").load("index.php #txtHint");
$("#total").load("index.php #total");
$("#total").load("index.php #total");


}
                    

</script>
<script type="text/javascript">
function price(str)
{
if (str=="")
  {
  document.getElementById("txtHint").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","update1.php?q="+str+"&price="+document.getElementById.('price1234'),true);xmlhttp.send();
$("#total").load("index.php #total");
$("#txtHint").load("index.php #txtHint");

}
                    

</script>

     
      <?php
// Query member data from the database and ready it for display
$sql mysql_query("SELECT * FROM cart where academy = '".$academy."' && cart_id = '".$cid."' order by id DESC");
while(
$row4 mysql_fetch_array($sql)){
$product $row4["product123"];
$price1 $row4["price"];
$id $row4["id"];
$qty $row4["quantity"];
if(
$product !=""){



?>

  
  <form name="delete" class="delete" method="POST" action=""> 
<button onClick="submitForm(<?php echo $id?>);return false"><img src="pics/x.jpg" height="59" style="height:25px; width:40px;"></button>
  <input type="hidden" name="hiddenField" value="<?php echo $id?>" />
  
  <?php  echo $product;
?>
</form>
<div id="name">

<form action="" class="update<?php echo $id?>" method="POST">
  
  <input name="id" type="hidden" value="<?php echo $id?>" />
    Quantity 
    <input name="qty" id="qty" type="text" value="<?php echo $qty?>" size="2" />$<input name="price1234" id="price1234"  type="text" value="<?php echo $price1?>" size="6" />Discount:<input name="discount" id="discount"  type="text" value="" size="6" />
    % off (format of 00, eg. 04)
    
    <input type="button" name="submit" value="update" onclick="update(<?php echo $id?>,qty.value,price1234.value,discount.value)" />
</form><hr /></div>


    <?php
    $price1 
$price1 $qty;
$total =  $price1 $total;
?>
<?php
}}
?>
      <br />
 
</div> <?php
// Query member data from the database and ready it for display
$sql mysql_query("SELECT * FROM products");
while(
$row5 mysql_fetch_array($sql)){
$product $row5["product"];
$id =$row5["id"];
$price =$row5["price"];

?>

<?php

}
?>  <div>
 <form action="" method="POST" name="empty" class="empty"> 

    <input name="cart_id" type="hidden" value="<?php echo $cid?>" /><input type="submit" name="empty" class="submit" value="empty cart" style="background-color:lightgreen; height:50px; width:100px;left:0px;" onclick="reload();">   </form> </div> <div>
   <form class="product" action="index.php" name="form12345" method="POST">
   </form>
   </div>
<script src="chosen/chosen.jquery.js" type="text/javascript"></script>
<script type="text/javascript"> $(".chzn-select").chosen(); $(".chzn-select-deselect").chosen({allow_single_deselect:true}); </script>
 <div id="total"><form name="pay" class="pay" method="POST" action="collect.php?total=<?php echo $total?>"> 
   <p>
     <?php if ($total == ""){$total "0";} ?>
     <?php setlocale(LC_MONETARY"en_US");
echo 
money_format("%n"$total);?>
     <?php
// Query member data from the database and ready it for display
$sql mysql_query("SELECT * FROM cart where cart_id = '".$_SESSION['cart_id']."' && academy= '$academy' && product123 !=''");
while(
$row mysql_fetch_array($sql)){
$product $row["product123"];
$price1 $row["price"];
$id $row["product_id"];
$qty $row["quantity"];



$month date("F Y"); 
$day date("d"); 
$year date("Y"); 
$date date("Y-m-d");
?>
     <input name="product[]" type="hidden" value="<?php echo $product?>" /><input name="academy[]" type="hidden" value="<?php echo $academy?>" /><input name="month[]" type="hidden" value="<?php echo $month?>" /><input name="day[]" type="hidden" value="<?php echo $day?>" /><input name="year[]" type="hidden" value="<?php echo $year?>" /><input name="date[]" type="hidden" value="<?php echo $date?>" /><input name="price[]" type="hidden" value="<?php echo $price1?>" /><input name="id[]" type="hidden" value="<?php echo $id?>" />
  <input name="qty[]" type="hidden" value="<?php echo $qty?>" /><?php
}
?> 
  <?php if ($total == " "){$total "0";} ?>
  <input type="hidden" value="<?php echo $total?>" name="total" />
<input type="submit" name="pay" id="pay" class="pay1" value="" />
 </form><br />
 
</div> 




<div id="TabbedPanels2" class="TabbedPanels">
  <ul class="TabbedPanelsTabGroup">
    <li class="TabbedPanelsTab" tabindex="0">Retail<br />
      <br />
      <br />
    </li>
    <li class="TabbedPanelsTab" tabindex="0">Trial Course<br />
      <br />
      <br />
    </li>
    <li class="TabbedPanelsTab" tabindex="0">Testing<br />
      <br />
      <br />
    </li>
    <li class="TabbedPanelsTab" tabindex="0">Events<br />
      <br />
      <br />
    </li>
    <li class="TabbedPanelsTab" tabindex="0">Birthday<br />
Parties<br />
      <br />
    </li>
    <li class="TabbedPanelsTab" tabindex="0">Enrollment <br />
      Fee<br />
      <br />
    </li>
    <li class="TabbedPanelsTab" tabindex="0">Memberships<br />
      <br />
      <br />
    </li>
    <li class="TabbedPanelsTab" tabindex="0">Packages<br />
      <br />
      <br />
  </li>
    <li class="TabbedPanelsTab" tabindex="0">Private<br />
lessons<br />
      <br />
    </li>
    <li class="TabbedPanelsTab" tabindex="0">Championships<br />
      <br />
      <br />
    </li>
</ul>
  <div class="TabbedPanelsContentGroup">
    <div class="TabbedPanelsContent"><div id="TabbedPanels3" class="TabbedPanels">
        <ul class="TabbedPanelsTabGroup">
          <li class="TabbedPanelsTab" style="background-color: #0CF;" tabindex="0">Main Retail<br />
            <br />
          </li>
          <li class="TabbedPanelsTab"  style="background-color: #0CF;"tabindex="0">Sparring/Ecas Gear<br />
            <br />
          </li>
          <li class="TabbedPanelsTab"  style="background-color: #0CF;" tabindex="0">Uniforms<br />
            <br />
          </li>
          <li class="TabbedPanelsTab"  style="background-color: #0CF;" tabindex="0">Manuals<br />
            <br />
          </li>
          <li class="TabbedPanelsTab"  style="background-color: #0CF;" tabindex="0">Patches<br />
            <br />
          </li>
        </ul>
        <div class="TabbedPanelsContentGroup">
          <div class="TabbedPanelsContent"> <?php
         
$sql 
mysql_query("SELECT * FROM products where category='retail' and subcategory='Main Retail' and city='$city'");
  
$i 0;
    echo 
"
    <table width='50%' cellpadding='0px' cellspacing='0px'><tr>"
;

        while(
$row mysql_fetch_assoc($sql)){
$product $row["product"];
$id =$row["id"];
$price =$row["price"];
$text $product;
$newtext wordwrap($text14);
$final1 ="".$newtext."
$"
.$price."";
 

echo 
"<td>";
?>

      
    

 <form action="" method="POST" name="myform<?php echo $id?>" class="myform<?php echo $id?>"> 
        <input type="hidden" name="hiddenField" class="hiddenField" value="<?php echo $product?>" />
        <input type="hidden" name="hiddenField2" class="hiddenField2" value="<?php echo $id?>" />
        <input type="hidden" name="hiddenField1" class="hiddenField1" value="<?php echo $price?>" />
      <input type="submit" name="submit" class="submit" value="<?php echo $final1?>" style="left: 0px; background-color:lightgreen; height:70px; width:100px;" onclick="update_data();">   </form>
<?php

echo "</td>";
if (
$i && $i%== 5) echo '</tr><tr>';
      
$i++;
    }
    
    echo 
"</table> ";
    
?>


     
</div>
          <div class="TabbedPanelsContent">
            <?php
         
$sql 
mysql_query("SELECT * FROM products where category='retail' and subcategory='Sparring/ECAS Gear' and city='$city'");
  
$i 0;
    echo 
"
    <table width='50%' cellpadding='0px' cellspacing='0px'><tr>"
;

        while(
$row mysql_fetch_assoc($sql)){
$product $row["product"];
$id =$row["id"];
$price =$row["price"];
$text $product;
$newtext wordwrap($text14);
$final1 ="".$newtext."
$"
.$price."";
 

echo 
"<td>";
?>

      
    

   
 
<!-- end .container --></div>

<script type="text/javascript">
var TabbedPanels2 = new Spry.Widget.TabbedPanels("TabbedPanels2");
var TabbedPanels3 = new Spry.Widget.TabbedPanels("TabbedPanels3");
</script>

</body>
</html>
Currently I have it set up so that a DIV will refresh after the product is submitted, only problem is that if the DIV refreshes before the database stores it, it doesn't update then.....that is why I would like to do this without any sort of http refresh at all... the code goes like that for a while, but hopefully you get the main idea(sorry it is so much lol)
searls03 is offline   Reply With Quote
Old 11-04-2012, 01:39 AM   PM User | #3
searls03
New Coder

 
Join Date: Jun 2011
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
searls03 is an unknown quantity at this point
PHP Code:
this is the code that I have:
[PHP]<?php
session_start
(); 
require_once 
"connect.php";
 

    
if(isset(
$_SESSION['logged'])){
    
// Query member data from the database and ready it for display

$cid $_SESSION['complete'];  
 
$academy $_SESSION['academy']; 
 if(
$academy=="Old_Cheney"){$city"Lincoln";}else if($academy=="Yankee_Hill"){$city"Lincoln";}else if($academy=="Holdrege"){$city"Lincoln";}else if($academy=="Maple"){$city"Omaha";}
 else if(
$academy=="Center"){$city"Omaha";}
 else if(
$academy=="Pensacola"){$city"Pensacola";}
$sql mysql_query("SELECT * FROM login where academy ='$academy'");
while(
$row mysql_fetch_array($sql)){
$date =$row["date"];
if (
$date !=="".date('m-d-Y')){echo '<meta http-equiv="REFRESH" content="0;url=login.php">';
   exit(); }
   

}
}else{
echo 
'<meta http-equiv="REFRESH" content="0;url=login.php">';
   exit(); 
}
if(
$academy=='all'){echo '<meta http-equiv="REFRESH" content="0;url=dashboard.php">';}


echo 
$cid;

echo 
$academy;
echo 
$city;

?>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>

<script src="SpryAssets/SpryTabbedPanels.js" type="text/javascript"></script><script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script>

<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery.validate/1.7/jquery.validate.min.js"></script>
<script src="SpryAssets/SpryTabbedPanels.js" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function(){
        $(".empty").validate({
            debug: false,
            
            submitHandler: function(form) {
                // do other stuff for a valid form
                $.post('empty.php', $(".empty").serialize(), function(data) {
                $("#total").load("index.php #total");    $("#txtHint").load("index.php #txtHint");
                });
            }
        });
    });
    </script>
   
<?php
// Query member data from the database and ready it for display
$sql mysql_query("SELECT * FROM cart where academy ='$academy' && cart_id = '".$cid."' ");
while(
$row mysql_fetch_array($sql)){
$id =$row["id"];

?>

    <script type="text/javascript">
    $(document).ready(function(){
        $("#delete<?php echo $id?>").validate({
            debug: false,
            
            submitHandler: function(form) {
                // do other stuff for a valid form
                $.post('delete.php', $("#delete<?php echo $id;?>").serialize(), function(data) {
                                    $("#total").load("index.php #total");
    $("#txtHint").load("index.php #txtHint");
                });
            }
        });
    });
    </script>
    <script type="text/javascript">
    $(document).ready(function(){
        $(".delete<?php echo $id2?>").validate({
            debug: false,
            
            submitHandler: function(form) {
                // do other stuff for a valid form
                $.post('delete.php', $(".delete<?php echo $id2;?>").serialize(), function(data) {
                    $("#total").load("index.php #total");$("#txtHint").load("index.php #txtHint");
                    
                });
            }
        });
    });
    </script>
   
    <?php
}
?>
    <?php
// Query member data from the database and ready it for display
$sql mysql_query("SELECT * FROM products");
while(
$row mysql_fetch_array($sql)){
$id =$row["id"];
?>
  <script type="text/javascript">
    $(document).ready(function(){
        $(".myform<?php echo $id?>").validate({
            debug: false,
            
            submitHandler: function(form) {
                // do other stuff for a valid form
                $.post('process.php', $(".myform<?php echo $id;?>").serialize(), function(data) {
                $("#total").load("index.php #total");    $("#txtHint").load("index.php #txtHint");
                });
            }
        });
    });
    </script> 
  

<?php

}
?>
  <script type="text/javascript">
    $(document).ready(function(){
        $("#myfor").validate({
            debug: false,
            
            submitHandler: function(form) {
                // do other stuff for a valid form
                $.post('process.php', $("#myfor").serialize(), function(data) {
                $("#total").load("index.php #total");    $("#txtHint").load("index.php #txtHint");
                });
            }
        });
    });
    </script> 
    


<link rel="stylesheet" href="chosen/chosen.css" />
  <script>
function update_data(){
// set up a point to the iFrame
var ifrm=document.getElementById('frame1');
ifrm.setAttribute('src', 'load_data.php');
document.getElementById('test123').value = document.getElementById('test123').value;
document.getElementById('price_text').value = document.getElementById('price').value;
document.getElementById('total_text').value = document.getElementById('total').value;

// the product_txtbox would be where you want the product to be place on your page, etc.
</script>
    
    <link href="SpryAssets/SpryTabbedPanels.css" rel="stylesheet" type="text/css" />
</head>

<body leftmargin="0">

<div class="container"> <a href="admin.php">Admin Panel</a> | <a href="void.php">Void Sale</a> | <a href="run.php">Balance the Drawer</a>  | <a href="logout.php">Logout</a><br /><form action="check.php" method="POST" name="" class="">
    <input name="cart_id" type="hidden" value="<?php echo $cid?>" /></form>  
  <div id="test123">
</div>

  <div id="container">
    <div class="side-by-side clearfix">
      <div> 
        <script type="text/javascript">
    $(document).ready(function submit(){
        $(".product").validate({
            debug: false,
            
            submitHandler: function(form) {
                // do other stuff for a valid form
                $.post('process1.php', $(".product").serialize(), function(data) {
                    $("#price").load("index.php #price");
                    $("#total").load("index.php #total");
                });
            }
        });
    });
    </script>
 
        

    </div>
  </div>
    

  
  <script src="chosen/chosen.jquery.js" type="text/javascript"></script>
  <script type="text/javascript"> $(".chzn-select").chosen(); $(".chzn-select-deselect").chosen({allow_single_deselect:true}); </script>
  <div id="txtHint"> 
     

    <script type="text/javascript">
function showUser(str)
{
if (str=="")
  {
  document.getElementById("txtHint").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","load_data.php?q="+str,true);
xmlhttp.send();
$("#total").load("index.php #total");
                    $("#txtHint").load("index.php #txtHint");

}
                    

</script>
</head>
    <script type="text/javascript">
    $(document).ready(function(){
        $(".update<?php echo $id 1?>").validate({
            debug: false,
            
            submitHandler: function(form) {
                // do other stuff for a valid form
                $.post('update.php', $(".update<?php echo $id 1;?>").serialize(), function(data) {
                    
                    $("#total").load("index.php #total");
                });
            }
        });
    });
    </script>
    <script type="text/javascript">
function submitForm(str)
{
if (str=="")
  {
  document.getElementById("txtHint").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","delete_data.php?q="+str,true);
xmlhttp.send();
$("#total").load("index.php #total");
                    $("#txtHint").load("index.php #txtHint");

}
                    

</script>
       <script type="text/javascript">
function update(str,dat,dat2,disc)
{
if (str=="")
  {
  document.getElementById("txtHint").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","update.php?q="+str+"&price="+dat2+"&qty="+dat+"&discount="+disc,true);xmlhttp.send();
$("#total").load("index.php #total");
$("#txtHint").load("index.php #txtHint");
$("#total").load("index.php #total");
$("#total").load("index.php #total");


}
                    

</script>
<script type="text/javascript">
function price(str)
{
if (str=="")
  {
  document.getElementById("txtHint").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","update1.php?q="+str+"&price="+document.getElementById.('price1234'),true);xmlhttp.send();
$("#total").load("index.php #total");
$("#txtHint").load("index.php #txtHint");

}
                    

</script>

     
      <?php
// Query member data from the database and ready it for display
$sql mysql_query("SELECT * FROM cart where academy = '".$academy."' && cart_id = '".$cid."' order by id DESC");
while(
$row4 mysql_fetch_array($sql)){
$product $row4["product123"];
$price1 $row4["price"];
$id $row4["id"];
$qty $row4["quantity"];
if(
$product !=""){



?>

  
  <form name="delete" class="delete" method="POST" action=""> 
<button onClick="submitForm(<?php echo $id?>);return false"><img src="pics/x.jpg" height="59" style="height:25px; width:40px;"></button>
  <input type="hidden" name="hiddenField" value="<?php echo $id?>" />
  
  <?php  echo $product;
?>
</form>
<div id="name">

<form action="" class="update<?php echo $id?>" method="POST">
  
  <input name="id" type="hidden" value="<?php echo $id?>" />
    Quantity 
    <input name="qty" id="qty" type="text" value="<?php echo $qty?>" size="2" />$<input name="price1234" id="price1234"  type="text" value="<?php echo $price1?>" size="6" />Discount:<input name="discount" id="discount"  type="text" value="" size="6" />
    % off (format of 00, eg. 04)
    
    <input type="button" name="submit" value="update" onclick="update(<?php echo $id?>,qty.value,price1234.value,discount.value)" />
</form><hr /></div>


    <?php
    $price1 
$price1 $qty;
$total =  $price1 $total;
?>
<?php
}}
?>
      <br />
 
</div> <?php
// Query member data from the database and ready it for display
$sql mysql_query("SELECT * FROM products");
while(
$row5 mysql_fetch_array($sql)){
$product $row5["product"];
$id =$row5["id"];
$price =$row5["price"];

?>

<?php

}
?>  <div>
 <form action="" method="POST" name="empty" class="empty"> 

    <input name="cart_id" type="hidden" value="<?php echo $cid?>" /><input type="submit" name="empty" class="submit" value="empty cart" style="background-color:lightgreen; height:50px; width:100px;left:0px;" onclick="reload();">   </form> </div> <div>
   <form class="product" action="index.php" name="form12345" method="POST">
   </form>
   </div>
<script src="chosen/chosen.jquery.js" type="text/javascript"></script>
<script type="text/javascript"> $(".chzn-select").chosen(); $(".chzn-select-deselect").chosen({allow_single_deselect:true}); </script>
 <div id="total"><form name="pay" class="pay" method="POST" action="collect.php?total=<?php echo $total?>"> 
   <p>
     <?php if ($total == ""){$total "0";} ?>
     <?php setlocale(LC_MONETARY"en_US");
echo 
money_format("%n"$total);?>
     <?php
// Query member data from the database and ready it for display
$sql mysql_query("SELECT * FROM cart where cart_id = '".$_SESSION['cart_id']."' && academy= '$academy' && product123 !=''");
while(
$row mysql_fetch_array($sql)){
$product $row["product123"];
$price1 $row["price"];
$id $row["product_id"];
$qty $row["quantity"];



$month date("F Y"); 
$day date("d"); 
$year date("Y"); 
$date date("Y-m-d");
?>
     <input name="product[]" type="hidden" value="<?php echo $product?>" /><input name="academy[]" type="hidden" value="<?php echo $academy?>" /><input name="month[]" type="hidden" value="<?php echo $month?>" /><input name="day[]" type="hidden" value="<?php echo $day?>" /><input name="year[]" type="hidden" value="<?php echo $year?>" /><input name="date[]" type="hidden" value="<?php echo $date?>" /><input name="price[]" type="hidden" value="<?php echo $price1?>" /><input name="id[]" type="hidden" value="<?php echo $id?>" />
  <input name="qty[]" type="hidden" value="<?php echo $qty?>" /><?php
}
?> 
  <?php if ($total == " "){$total "0";} ?>
  <input type="hidden" value="<?php echo $total?>" name="total" />
<input type="submit" name="pay" id="pay" class="pay1" value="" />
 </form><br />
 
</div> 




<div id="TabbedPanels2" class="TabbedPanels">
  <ul class="TabbedPanelsTabGroup">
    <li class="TabbedPanelsTab" tabindex="0">Retail<br />
      <br />
      <br />
    </li>
    <li class="TabbedPanelsTab" tabindex="0">Trial Course<br />
      <br />
      <br />
    </li>
    <li class="TabbedPanelsTab" tabindex="0">Testing<br />
      <br />
      <br />
    </li>
    <li class="TabbedPanelsTab" tabindex="0">Events<br />
      <br />
      <br />
    </li>
    <li class="TabbedPanelsTab" tabindex="0">Birthday<br />
Parties<br />
      <br />
    </li>
    <li class="TabbedPanelsTab" tabindex="0">Enrollment <br />
      Fee<br />
      <br />
    </li>
    <li class="TabbedPanelsTab" tabindex="0">Memberships<br />
      <br />
      <br />
    </li>
    <li class="TabbedPanelsTab" tabindex="0">Packages<br />
      <br />
      <br />
  </li>
    <li class="TabbedPanelsTab" tabindex="0">Private<br />
lessons<br />
      <br />
    </li>
    <li class="TabbedPanelsTab" tabindex="0">Championships<br />
      <br />
      <br />
    </li>
</ul>
  <div class="TabbedPanelsContentGroup">
    <div class="TabbedPanelsContent"><div id="TabbedPanels3" class="TabbedPanels">
        <ul class="TabbedPanelsTabGroup">
          <li class="TabbedPanelsTab" style="background-color: #0CF;" tabindex="0">Main Retail<br />
            <br />
          </li>
          <li class="TabbedPanelsTab"  style="background-color: #0CF;"tabindex="0">Sparring/Ecas Gear<br />
            <br />
          </li>
          <li class="TabbedPanelsTab"  style="background-color: #0CF;" tabindex="0">Uniforms<br />
            <br />
          </li>
          <li class="TabbedPanelsTab"  style="background-color: #0CF;" tabindex="0">Manuals<br />
            <br />
          </li>
          <li class="TabbedPanelsTab"  style="background-color: #0CF;" tabindex="0">Patches<br />
            <br />
          </li>
        </ul>
        <div class="TabbedPanelsContentGroup">
          <div class="TabbedPanelsContent"> <?php
         
$sql 
mysql_query("SELECT * FROM products where category='retail' and subcategory='Main Retail' and city='$city'");
  
$i 0;
    echo 
"
    <table width='50%' cellpadding='0px' cellspacing='0px'><tr>"
;

        while(
$row mysql_fetch_assoc($sql)){
$product $row["product"];
$id =$row["id"];
$price =$row["price"];
$text $product;
$newtext wordwrap($text14);
$final1 ="".$newtext."
$"
.$price."";
 

echo 
"<td>";
?>

      
    

 <form action="" method="POST" name="myform<?php echo $id?>" class="myform<?php echo $id?>"> 
        <input type="hidden" name="hiddenField" class="hiddenField" value="<?php echo $product?>" />
        <input type="hidden" name="hiddenField2" class="hiddenField2" value="<?php echo $id?>" />
        <input type="hidden" name="hiddenField1" class="hiddenField1" value="<?php echo $price?>" />
      <input type="submit" name="submit" class="submit" value="<?php echo $final1?>" style="left: 0px; background-color:lightgreen; height:70px; width:100px;" onclick="update_data();">   </form>
<?php

echo "</td>";
if (
$i && $i%== 5) echo '</tr><tr>';
      
$i++;
    }
    
    echo 
"</table> ";
    
?>


     
</div>
          <div class="TabbedPanelsContent">
            <?php
         
$sql 
mysql_query("SELECT * FROM products where category='retail' and subcategory='Sparring/ECAS Gear' and city='$city'");
  
$i 0;
    echo 
"
    <table width='50%' cellpadding='0px' cellspacing='0px'><tr>"
;

        while(
$row mysql_fetch_assoc($sql)){
$product $row["product"];
$id =$row["id"];
$price =$row["price"];
$text $product;
$newtext wordwrap($text14);
$final1 ="".$newtext."
$"
.$price."";
 

echo 
"<td>";
?>

      
    

   
 <form action="" method="POST" name="myform<?php echo $id?>" class="myform<?php echo $id?>"> 
        <input type="hidden" name="hiddenField" class="hiddenField" value="<?php echo $product?>" />
        <input type="hidden" name="hiddenField2" class="hiddenField2" value="<?php echo $id?>" />
        <input type="hidden" name="hiddenField1" class="hiddenField1" value="<?php echo $price?>" />
      <input type="submit" name="submit" class="submit" value="<?php echo $final1?>" style="background-color:lightgreen; height:70px; width:120px;" onclick="reload();">   </form>
<?php
echo "</td>";
if (
$i && $i%== 4) echo '</tr><tr>';
      
$i++;
    }
    
    echo 
"</table> ";
    
?>

          </div>
          <div class="TabbedPanelsContent"> <?php
         
$sql 
mysql_query("SELECT * FROM products where category='retail' and subcategory='Uniforms' and city='$city'");
  
$i 0;
    echo 
"
    <table width='50%' cellpadding='0px' cellspacing='0px'><tr>"
;

        while(
$row mysql_fetch_assoc($sql)){
$product $row["product"];
$id =$row["id"];
$price =$row["price"];
$text $product;
$newtext wordwrap($text14);
$final1 ="".$newtext."
$"
.$price."";
 

echo 
"<td>";
?>

      
    

   

<p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
<!-- end .content --></div>
 
<!-- end .container --></div>

<script type="text/javascript">
var TabbedPanels2 = new Spry.Widget.TabbedPanels("TabbedPanels2");
var TabbedPanels3 = new Spry.Widget.TabbedPanels("TabbedPanels3");
</script>

</body>
</html>
[/PHP]It just goes on like this for awhile then....hopefully you can help me out (sorry for so much code lol)

Last edited by searls03; 11-04-2012 at 01:41 AM..
searls03 is offline   Reply With Quote
Old 11-04-2012, 03:17 PM   PM User | #4
searls03
New Coder

 
Join Date: Jun 2011
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
searls03 is an unknown quantity at this point
but that wouldn't make it so that it doesn't refresh the div, would it? That is waht I want, the div not to refresh....

Only one "$(document).ready(function()"

Put all of your jquery here:
Quote:
Code:
---------
<script type="text/javascript">
$(document).ready(function(){

ALL JQUERY GOES HERE. NOT ALL OVER THE PLACE.
});
</script>
---------
searls03 is offline   Reply With Quote
Old 11-04-2012, 05:30 PM   PM User | #5
sunfighter
Senior Coder

 
Join Date: Jan 2011
Location: Missouri
Posts: 2,498
Thanks: 18
Thanked 361 Times in 360 Posts
sunfighter is on a distinguished road
I deleted cause I didn't want to get involved with this, but you caught me. It's like having two or more ID's with the same name. The browser don't now which one. The $(document).ready(function() is where the browser goes after the page loads, yours don't know where to go. (simplified)

You have a number of errors in your coding. Putting your js/jq together will help you find them.
function update_data() has no end }. You duplicate your ajax object in function showUser(), function submitForm(), function update(), and function price(). These are done in javascript but you use jquery for a number of other ajax post calls, why not have some consistency? Is any of this responsible for your problems? Possible, I don't know. Cleaner code would help tremendously.

Since things 'refresh', I'd say it's in the js/jq code and not the php. But your php has errors in writing the html. At lest that's what my editor says.

Sorry I couldn't be more help. Clean up the code and see what happens.
There is always http://validator.w3.org/
sunfighter is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:34 AM.


Advertisement
Log in to turn off these ads.