1
<?php
include "config.php";

// Fetch the data

$con = mysql_query("select * from product");
?>
<div style=" height:250px; overflow:auto;">
    <table class="table table-striped table-bordered dTableR" id="ajxtable">
        <tr>
            <th>Jobno</th>
            <th>Product</th>
            <th>Qty</th>
            <th>Designed by</th>
            <th>Action</th>
        </tr>
        <?php
        while ($row = mysql_fetch_array($con)) {
            $id       = $row['id'];
            $pcode    = $row['pcode'];
            $lproduct = $row['lproduct'];
            $mrprate  = $row['mrprate'];
            ?>
            <tr>
                <td><?php echo $id; ?></td>
                <td><?php echo $lproduct; ?></td>
                <td><?php echo $mrprate; ?></td>
                <td><?php echo "admin"; ?></td>
                <td><input type="button" id="addmorePOIbutton1" style="width:25px;" value="+" onClick=""/>
                    <input type="button" id="delPOIbutton1" style="width:25px;" value="-" onClick=""/></td>
            </tr>
        <?php
        }
        ?>
    </table>
</div>

This is ajax page. Below table is auto refreshed every 5 seconds.

My doubt is how to get that particular row value.

When i click table row + button, get these particular row values, and place to index page text box and this '+' button also hide.

Kindly suggest any jquery or ajax code for adding below code.

I am new to jquery ,,anybody help me with sample code..that would help me greately. Thanks in advance

colburton
  • 4,685
  • 2
  • 26
  • 39
  • possible duplicate of [jQuery: Get the contents of a table row with a button click](http://stackoverflow.com/questions/14460421/jquery-get-the-contents-of-a-table-row-with-a-button-click) – martynas Jun 23 '14 at 08:48
  • This is not a `code my app for me` site. Identify a specific issue, document it, show what you have already tried. Then you can expect some help. – RiggsFolly Jun 23 '14 at 09:03
  • Above code is ajax page code. This table display on my index page (by using div). When i click + button above table, that particular row value (jobno,product, qty) are place to index page 3 text box. how to get the value and transfer to index page text box. – user3758953 Jun 23 '14 at 09:34
  • Mr.martynas , that link code is not working in ajax page. it's work only run separately. – user3758953 Jun 23 '14 at 09:54
  • Dont use `mysql`! use `mysqli` instead – Ramon Bakker Apr 14 '16 at 07:41
  • and a query is not a connection, so the var `$con` should be `$query` or something. Its not causing errors or somerthing, its just the programming style thats incorrect – Ramon Bakker Apr 14 '16 at 07:45

1 Answers1

0
$(document).ready(function () {      
     $('#yourtablename tr').click(function (event) {
          alert($(this).attr('id')); //trying to alert id of the clicked row          

     });
 });

Above code may be help you and another solution is:

 $('td').click(function(){
       var row_index = $(this).parent().index();
       var col_index = $(this).index();
    });
Bhatt Akshay
  • 159
  • 1
  • 14