Forum Moderators: open
<script language="javascript" type="text/javascript">
<!--
//Browser Support Code
function ajaxFunction(){
var ajaxRequest; // The variable that makes Ajax possible!
try{
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e){
// Internet Explorer Browsers
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
// Something went wrong
alert("Your browser broke!");
return false;
}
}
}
// Create a function that will receive data sent from the server
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
var ajaxDisplay = document.getElementById('ajaxDiv');
ajaxDisplay.innerHTML = ajaxRequest.responseText;
}
}
<?php for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {//set the arrays
?>
var prid = document.getElementById('prid<?php echo '['.$i.']';?>').value;
var stock = document.getElementById('stock<?php echo '['.$i.']';?>').value;
<?php //end arrays
}
?>
var queryString = "?prid=" + prid + "&stock=" + stock;
ajaxRequest.open("GET", "ajax_product.php" + queryString, true);
ajaxRequest.send(null);
}
//-->
</script> for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
echo'<form id="ajaxupdate" name="ajaxupdate">
<input type="checkbox" id="prid['.$i.']" name="prid['.$i.']" value="'.$order->products[$i]['orders_products_id'].'" onclick="ajaxFunction()">
<input type="hidden" id="stock['.$i.']" value="'.$order->products[$i]['stock_marked'].'">
<input type="hidden" id="pname['.$i.']" name="pname" value="'.$order->products[$i]['products_name'].'">
</form>';
}
<script language="javascript" type="text/javascript">
<!--
//Browser Support Code
function ajaxFunction(){
var ajaxRequest; // The variable that makes Ajax possible!
try{
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e){
// Internet Explorer Browsers
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
// Something went wrong
alert("Your browser broke!");
return false;
}
}
}
// Create a function that will receive data sent from the server
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
var ajaxDisplay = document.getElementById('ajaxDiv');
ajaxDisplay.innerHTML = ajaxRequest.responseText;
}
}
var prid = document.getElementById('prid[0]').value;
var stock = document.getElementById('stock[0]').value;
var prid = document.getElementById('prid[1]').value;
var stock = document.getElementById('stock[1]').value;
var prid = document.getElementById('prid[2]').value;
var stock = document.getElementById('stock[2]').value;
var prid = document.getElementById('prid[3]').value;
var stock = document.getElementById('stock[3]').value;
var prid = document.getElementById('prid[4]').value;
var stock = document.getElementById('stock[4]').value;
var queryString = "?prid=" + prid + "&stock=" + stock;
ajaxRequest.open("GET", "ajax_product.php" + queryString, true);
ajaxRequest.send(null);
}
//-->
</script> <form id="ajaxupdate" name="ajaxupdate">
<input id="prid[0]" name="prid[0]" value="148856" onclick="ajaxFunction()" type="checkbox">
<input id="stock[0]" value="0" type="hidden">
<input id="pname[0]" name="pname" value="" type="hidden">
</form>
<input name="products_purchased148857" value="1" type="hidden">
<div class="display[1]">
<form id="ajaxupdate" name="ajaxupdate">
<input id="prid[1]" name="prid[1]" value="148857" onclick="ajaxFunction()" type="checkbox">
<input id="stock[1]" value="0" type="hidden">
<input id="pname[1]" name="pname" value="" type="hidden">
</form>
<input name="products_purchased148858" value="1" type="hidden"><div class="display[2]">
</form>
<form id="ajaxupdate" name="ajaxupdate">
<input id="prid[2]" name="prid[2]" value="148858" onclick="ajaxFunction()" type="checkbox">
<input id="stock[2]" value="2" type="hidden">
<input id="pname[2]" name="pname" value="" type="hidden">
</form>
<?php for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {//set the arrays
?>
var prid = document.getElementById('prid<?php echo '['.$i.']';?>').value;
var stock = document.getElementById('stock<?php echo '['.$i.']';?>').value;
<?php //end arrays
}
?>
var prid = document.getElementById('prid[0]').value;
var stock = document.getElementById('stock[0]').value;
var prid = document.getElementById('prid[1]').value;
var stock = document.getElementById('stock[1]').value;
var prid = document.getElementById('prid[2]').value;
var stock = document.getElementById('stock[2]').value;
var prid = document.getElementById('prid[3]').value;
var stock = document.getElementById('stock[3]').value;
var prid = document.getElementById('prid[4]').value;
var stock = document.getElementById('stock[4]').value;
var prid[0] = document.getElementById('prid[0]').value;
var stock[0] = document.getElementById('stock[0]').value;
var prid[1] = document.getElementById('prid[1]').value;
var stock[1] = document.getElementById('stock[1]').value;
var queryString = "?prid[]=" + prid[] + "&stock[]=" + stock[];
ajaxRequest.open("GET", "ajax_product.php" + queryString, true);
ajaxRequest.send(null);
Error: missing ; before statement
Source File: script.php
Line: 53, Column: 5
Source Code:
var prid[0] = document.getElementById('prid[0]').value;
var prid[0] = document.getElementById('prid[0]').value;
var prid[1] = document.getElementById('prid[1]').value;
var prid = [];
prid[0] = document.getElementById('prid[0]').value;
prid[1] = document.getElementById('prid[1]').value;
Error: syntax error
Source File: script.php
Line: 59, Column: 37
Source Code:
var queryString = "?prid[]=" + prid[] + "&stock[]=" + stock[];
var prid = [];
var stock = [];
prid[0] = document.getElementById('prid[0]').value;
stock[0] = document.getElementById('stock[0]').value;
prid[1] = document.getElementById('prid[1]').value;
stock[1] = document.getElementById('stock[1]').value;
var queryString = "?prid[]=" + prid[] + "&stock[]=" + stock[];
ajaxRequest.open("GET", "ajax_product.php" + queryString, true);
ajaxRequest.send(null);
for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {//set the arrays
//get id
$pid = (int)$_POST['prid']['.$i.'];
}
$qry_result = mysql_query("UPDATE orders_products SET products_stock_detail ='1' where orders_products_id='".$pid."'") or die(mysql_error());