Jump to content

Recommended Posts

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.