Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1096585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:18:16+00:00 2026-05-17T00:18:16+00:00

<?php foreach ($list as $item): ?> <tr> <td> <div id=<?php echo $item[‘id’]; ?>> <input

  • 0
<?php foreach ($list as $item): ?>
  <tr>
    <td>
    <div id="<?php echo $item['id']; ?>">
    <input type="text" name="name" id="name"/>
    <button type="submit" id="ajax_submit" value="<?php echo $item['id']; ?>">run</button>
    </div>
    </td>
  </tr>
<?php endforeach; ?>

In this php-code I generate html table. When user click on button they activate this JQuery script

 <script>
   $(document).ready(function(){
     $('button').click(function(){
       var id = "#" + $("button").val();
          $.post("data/js", { name: $("#name").val(),id : id },
           function(data){
            $(id).html(data);
         });
       })
    });
 </script>

But, when I want select non-first button in table, script run function for first. Please help to do all normal.

PS sorry for my english ;-(

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T00:18:17+00:00Added an answer on May 17, 2026 at 12:18 am

    Try this:

    <?php foreach ($list as $item): ?>
      <tr>
        <td>
        <div id="<?php echo $item['id']; ?>">
        <input type="text" name="name" id="name"/>
        <button type="submit" id="ajax_submit_<?php echo $item['id']; ?>" value="<?php echo $item['id']; ?>">run</button>
        </div>
        </td>
      </tr>
    <?php endforeach; ?>
    

    ..

    <script>
       $(document).ready(function(){
         $('button').click(function(){
           var id = $(this).attr('value');
              $.post("data/js", { name: $(this).prev().attr('name'),id : id },
               function(data){
                $(id).html(data);
             });
           })
        });
     </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

for example i have: <?php foreach($query as $q): ?> <div class=item> <?php echo img($q->images);
For example in php I have a list of clients: foreach($clients as $client) echo
I use this : <?php foreach($_SERVER as $key => $value){ echo <b>$key:</b> $value<br>\n; }
<?php foreach($pricelistline as $value) { $e = explode(,,$value); if ($e[0]) { echo <li>\n<img width=\24\
I have a list structure like this: <ul id=part> <?php $i=0; foreach ($q as
i have this in buy.php <form action=cart.php> <?php echo'<input style=width:10px; margin-left:9px; name=price[] type=checkbox value='
I have this section of code: <select id=frm_type name=typeId> <?php foreach($product_types as $product) :
So I have a php foreach loop as follows, $i = 1; foreach($rows as
I am working with a PHP foreach loop and I need it to output
I have an onclick event called in a PHP foreach loop for several items

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.