php - My jquery code does not work after for loop -


i trying iterate through textboxes in form using jquery. working fine other day , stopped working. understand has happened wrong sure couldn't identify. please me out of trouble if see error here code:

<?php $serial = 0; while ($row_details = mysql_fetch_array($res_details)) {     $serial++;     $remaining_qty = $row_details['ordered_qty'] - $row_details['received_qty'];     echo '<tr>';     echo '<td>' . $serial . '.<input type="hidden" name="pcode-' . $serial . '" id="pcode-' . $serial . '" value="' . $row_details['product_code'] . '"/></td>';     echo '<td>' . $row_details['product_name'] . ' [' . $row_details['product_code'] . ']</td>';     echo '<td>' . $row_details['ordered_qty'] . '</td>';     echo '<td>' . $row_details['received_qty'] . '</td>';     echo '<td>' . $remaining_qty . '<input type="hidden" name="remain-' . $serial . '" id="remain-' . $serial . '" value="' . $remaining_qty . '"/></td>';     echo '<td><input type="text" name="newreceive-' . $serial . '" id="newreceive-' . $serial . '" size="5" class="money-field" value="' . $remaining_qty . '"/></td>';     echo '</tr>'; } ?>  <script type="text/javascript"> var count = <?php echo $serial; ?>;// count no of rows var verified = true; (var = 1; <= count; i++) {     if ($("#pcode-" + i).val().length > 0) {         if (parseint($("#remain-" + i).val()) < parseint($("#newreceive-" + i).val())) {             verified = false;         }     }     alert("iteration" + i); }  /* after line code not works*/ alert("inside verify()"); if (verified) {     alert("verification successful");     $("#update").removeattr('disabled'); } else {     alert("verification failed");     $("#update").attr('disabled', 'disabled'); } </script> 

this inside function verify() called on button click. code not work after for loop.

i think should use parseint count , loop should break after verified=false; like,

var count = <?php echo $serial; ?>;// count no of rows var verified = true; (var = 1; <= parseint(count); i++) {// parseint count     if ($("#pcode-" + i).val().length > 0) {         if (parseint($("#remain-" + i).val()) < parseint($("#newreceive-" + i).val())) {             verified = false;             break;// break loop if validation fails         }     }     alert("iteration" + i); } 

updated try tested works @ end

<script>     $(function(){         var count = <?php echo $serial; ?>;// count no of rows         var verified = true;         (var = 1; <= parseint(count); i++) {             if ($("#pcode-" + i).val().length > 0) {                 if (parseint($("#remain-" + i).val()) < parseint($("#newreceive-" + i).val())) {                     verified = false;break;                 }             }             alert("iteration" + i);         }          /* after line code not works*/         alert("inside verify()");         if (verified) {             alert("verification successful");             $("#update").removeattr('disabled');         }         else {             alert("verification failed");             $("#update").attr('disabled', 'disabled');         }     }); </script> 

Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -