searls03 Posted February 4, 2012 Share Posted February 4, 2012 submission code: <?php // Query member data from the database and ready it for display $sql = mysql_query("SELECT * FROM cart where cart_id = ".$cid.""); while($row = mysql_fetch_array($sql)){ $id =$row["id"]; ?> <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 type="text/javascript"> $(document).ready(function(){ $(".update<?php echo $id; ?>").validate({ debug: false, submitHandler: function(form) { // do other stuff for a valid form $.post('update.php', $(".update<?php echo $id;?>").serialize(), function(data) { $("#price").load("index.php #price");$("#total").load("index.php #total"); }); } }); }); </script> <?php } ?> form: <?php // Query member data from the database and ready it for display $sql = mysql_query("SELECT * FROM cart where cart_id = ".$cid.""); while($row = mysql_fetch_array($sql)){ $product = $row["product123"]; $price1 = $row["price"]; $id = $row["id"]; $qty = $row["quantity"]; if($product !=""){ ?> <form action="" class="update<?php echo $id; ?>" method="POST"> <input name="id" type="hidden" value="<?php echo $id; ?>" /> Quantity <input name="qty" type="text" value="<?php echo $qty; ?>" size="2" />$ <input name="price" type="text" value="<?php echo $price1; ?>" size="6" /> <input type="submit" name="update" id="update" value="update" /> </form> . so my problem is that only everyother time does the page actually not refresh.......so one time it does and database doesn't update......second time it doesn't refresh and it updates(this is what I want). why is it doing this? is it because it is inside a div that gets refreshed? if this is the problem....how do I fix it? Quote Link to comment https://forums.phpfreaks.com/topic/256389-help-with-form-submission/ Share on other sites More sharing options...
searls03 Posted February 5, 2012 Author Share Posted February 5, 2012 does anyone know how to fix this? Quote Link to comment https://forums.phpfreaks.com/topic/256389-help-with-form-submission/#findComment-1314846 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.