Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

288
Views
How can append td in same row in table using jQuery

enter image description here

$(document).ready(function() {
  $('.zk_btn').click(function(e) {
    var pass_symbol= $('#' + lastid).val();
    var split_id = lastid.split("_");
    var nextindex = Number(split_id[1]) + 1;

    $.ajax({
      url:"record_count_3.php?pass_symbol=" + pass_symbol,
      method:"POST",
      success:function(data)
        {
        var json = JSON.parse(data);
        var txt = '';

        if(json.length > 0){
          for(var i=0;i<json.length;i++){
            txt = "<td>"+json[i].openrate+"</td><td>"+json[i].highrate+"</td><td>"+json[i].lowrate+"</td><td>"+json[i].closerate+"</td>";
                                                
            $("#example > tbody > tr").append(txt);
          }
          $('#example > tbody').append('<tr class="txt_ '+  nextindex +'"><td><input type="text" id="txt_'+ nextindex +'" name="symbol"  class="txtfield"  /></td></tr> </tbody>');
        }   
        $('.content').html(data);
      }
    })
  });
});

I have a problem iam fetching data from ajax call and move in json varibale.when write symbol in input box and fetching records and display in 1st td,and append in new row. and another insert symbol and click submit button fetching the record and display in second td but problem second record display in first row and second row just like screen shot. mcb records display in 2nd row not in 1st row. please suggest my mistake

  <table id='example' border='1' cellspacing='1' cellpadding='1' style='width:900px;' >
    <thead>
      <th> Marksymbol</th>
      <th class='namecol '> Openrate</th>
      <th class='namecol'> Highrate</th>
      <th class='namecol'> Lowrate</th>
      <th class='namecol'> Closerate</th>
    </tr>
  </thead>
  <tbody>
    <tr class ='txt_1'>
      <td > <input type='text' name="symbol" id='txt_1'  class='txtfield'/>
      </td>
    </tr>
                                            
</table>

<input type="button" id= "btnclick" class="zk_btn zk_btn_submit" name="submit1" value="SUBMIT"/> 
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

It's working now

$('#example tr:last').closest('tr').append(txt);
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!