Ok so i have this javascript
function getpreconfigproducts(str1,str2)
{
var url="ajax_preconfig_products.php?";
url=url+"id="+str1+"&cid="+str2;
xmlHttp = GetXmlHttpObject(stateChangeHandler);
xmlHttp_Get(xmlHttp, url);
return false;
}
and it calls this php
<?php
if($_GET['id']!='')
{
$sql="SELECT * FROM productinfo WHERE ProductID=".$_GET['id']." AND Status=1";
$pro=ExecuteGetRows($sql);
?>
<p>Qty: <input type="input" name="qty[]" id="fpro[]" value="1" style="width:15px; margin-top:-3px;" /> <label><?php echo $pro[0]['ProductName'];?></label> </p>
<?php
echo "^_^";
echo ",".$pro[0]['ProductID'];
} ?>
which generates this
<div class="fields">
<h2>Final Products</h2>
<p id="finalproductsid">
<p>Qty: <input name="qty[]" id="fpro[]" value="1" style="width: 15px; margin-top: -3px;" type="input"> <label>FIREBOX S5510 15</label> </p>
<p>Qty: <input name="qty[]" id="fpro[]" value="1" style="width: 15px; margin-top: -3px;" type="input"> <label>FIREBOX S5510 15</label> </p>
</p>
</div>
The problem is that if a user changes the input qty[] to say 5 and adds another product it reverts back to 1 …any ideas how i can address this
Aside from all the SQL injection stuff, mentioned already, I think I might know what your problem is. Tell me if I understand your script:
I’m assuming #4 is where the problem (#5) is occurring. Depending on how you append the HTML to the form, the input fields will sometimes revert. For instance:
May I suggest, that instead of appending a string of HTML, you create the HTML with JavaScript, getting the product name/id through an AJAX request.
I don’t quite understand how your script is working though. As far as my limited knowledge goes, the PHP isn’t displaying onto the current page, but echoing to the AJAX’s response text. Is there something more, or is it just me?