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 5945561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:41:58+00:00 2026-05-22T16:41:58+00:00

I have the following HTML table: <table width=800 border=0 align=center class=pretty-table id=tabel_sectiunea_c2a> <thead> <tr>

  • 0

I have the following HTML table:

<table width="800" border="0" align="center" class="pretty-table" id="tabel_sectiunea_c2a">
      <thead>
        <tr>
          <td width="800" colspan="4"><strong>Situaţia misiunilor de audit al situaţiilor financiare finalizate în calitate de contractant principal</strong></td>
        </tr>
        <tr>
          <td width="200">Indicativ client (CP)</td>
          <td width="200">Onorarii (conform contractului)</td>
          <td width="200">Număr ore planificate</td>
          <td width="200">Onorarii cedate subcontractanţilor</td>
        </tr>
      </thead>
      <tr>
        <td><strong>Total</strong></td>
        <td><label for="total_onorarii_contract"></label>
          <input name="total_onorarii_contract" type="text" id="total_onorarii_contract" value="0" readonly="readonly" /></td>
        <td><input name="total_numar_ore_planificate" type="text" id="total_numar_ore_planificate" value="0" readonly="readonly" /></td>
        <td><input name="total_onorarii_cedate" type="text" id="total_onorarii_cedate" value="0" readonly="readonly" /></td>
      </tr>
      <tr>
        <td>C<span>1</span></td>
        <td><input type="text" name="onorarii_contract[]" id="onorarii_contract[]" /></td>
        <td><input type="text" name="numar_ore_planificate[]" id="numar_ore_planificate[]" /></td>
        <td><input type="text" name="onorarii_cedate[]" id="onorarii_cedate[]" /></td>
      </tr>
    </table>
    <br />
    <p><a href="#" id="rand_nou_tabel_sectiunea_c2a">Adauga un rand nou</a></p>

What I would to do is to add another table row like this one:

<tr>
   <td>C<span>1</span></td>
   <td><input type="text" name="onorarii_contract[]" id="onorarii_contract[]" /></td>
   <td><input type="text" name="numar_ore_planificate[]" id="numar_ore_planificate[]" /></td>
   <td><input type="text" name="onorarii_cedate[]" id="onorarii_cedate[]" /></td>
</tr>

and increment the number between <span></span> when I click that href at the end of the table.

I have the following jQuery code but it doesn’t seem to work:

<script type="text/javascript" charset="utf-8">
    $(document).ready(function() {
        $("#rand_nou_tabel_sectiunea_c2a").click(function() {
            $('#tabel_sectiunea_c2a tr:last').after('<tr><td><span></span></td><td><input type="text" name="onorarii_contract[]" id="onorarii_contract[]" /></td><td><input type="text" name="numar_ore_planificate[]" id="numar_ore_planificate[]" /></td><td><input type="text" name="onorarii_cedate[]" id="onorarii_cedate[]" /></td></tr>');
            $('#tabel_sectiunea_c2a tr:gt(3) td:nth-child(1) span').each(function(i){
                var newVal = 1+parseInt($(this).text(), 10);
                $(this).html('C'+newVal);
            });
        });
    });
</script>

When I click the href I get a new line, but instead of incrementing that integer value, I get “CNan”.

Can you please help me figure it out?

Thank you.

  • 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-22T16:41:58+00:00Added an answer on May 22, 2026 at 4:41 pm

    I think you’re grossly overcomplicating your code. Because there’s no number in the HTML that you insert, it gets parsed as NaN by parseInt.

    It would be far easier to use clone on the final table row and then modify that with text:

    $("#rand_nou_tabel_sectiunea_c2a").click(function(e) {
        e.preventDefault(); // prevent any jumping
    
        var newRow = $('#tabel_sectiunea_c2a tr:last').clone(true); // clone the last row in the table
    
        newRow.find('td:first-child span').text(function(i, oldText) {
            return parseInt(oldText, 10) + 1; // increment the number in the span
        });
    
        newRow.find('input:text').val(''); // blank the inputs
    
        $('#tabel_sectiunea_c2a').append(newRow); // add the new row to the table
    });
    

    See working jsFiddle.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following table in my HTML: <div style=max-width:700px;> <table border=1> <tr><td colSpan=2>this
I have the following html page: <body> <div class=hide1 style=width:1000px; height:1000px;> <table width=100% border=0
I have the following HTML table: <table style=width: 100%;> <tr> <td class=title_bar_left_border></td> <td class=title_bar_middle></td>
I have following HTML table: <form method=post action=update-table.php> <table class=table-data style=width: 960px;> <thead> <tr>
I have following html: <table width=100%;> <tr><hr style=width:100%;></hr></tr> <tr> <span style=float:left>abc</span> <span class=noindex style=float:right>PageID</span>
I have the following html code. <html> <body> <div style=max-width:1600px; min-width:900px; > <table> </table>
I have the following HTML: <div style=30px;> <table width=100%;> <tr> <td> <SELECT name=guidelinks> <OPTION
Let's say I have the following HTML: <table id=foo> <th class=sortasc>Header</th> </table> <table id=bar>
I have the following: <ul style=width: 300px; list-style-type:none> <li> <table style=width:100% border=0 cellpadding=0 cellspacing=0
I have the following HTML table format: <table style=width: 100%;> <tr> <td> //How to

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.