dheerajtrivedi Posted March 21, 2012 Share Posted March 21, 2012 I have a php form where fields are created using while loop. I want that when the user inputs a value in the first field, the value corresponding in the database should be fetched in the corresponding field. I have used ajax for this but it always gives the result in the first row and not in the second row. I have also tried jquery with no success. Below is my code..any suggestions... <code> <?php $a=$_REQUEST['iqty'][$count]; $ctr=$a; while($a>0) { ?> <tr align="center"> <td valign="top"> </td> <td valign="top"> </td> <td valign="top"> </td> <td valign="top"> </td> <td valign="top"> </td> <td> </td> <td><input name="asset_no[]" type="text" class="txt_field_n" style="width:120px" id="asset_no[]" onKeyUp="check();" /> <input name="rel1[]" id="req_no5" type="hidden" value="<?php echo $ad;?>"/><input name="ctr" id="ctr" type="hidden" value="<?php echo $ctr ?>" /></td> <td> <p> <?php if($sr_req=='Yes') { ?> <div id="srdiv"><input name="sr_no[]" type="text" class="txt_field_n" style="width:120px" id="sr_no[]"/><input name="test[]" id="test[]" type="hidden" /></div> <?php } else { ?> <input name="sr_no[]" type="text" class="txt_field_n" style="width:120px;background-color:#BDE9FD" id="sr_no[<?php echo $ctr ?>]" readonly="readonly"/> <?php } ?> </td> <td> <?php if($require=='Yes') { ?> <input name="mac_add[]" type="text" class="txt_field_n" style="width:120px" id="mac_add"/> <?php } else { ?> <input name="mac_add[]" type="text" class="txt_field_n" style="width:120px; background-color:#BDE9FD" id="mac_add" readonly="readonly"/> <?php } ?> </td> </tr> <?php $a=$a-1; $ctr=$ctr-1; } ?> <?php }?> </code> Any suggestions,help Link to comment https://forums.phpfreaks.com/topic/259406-autofill-rray-fields-in-php/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.