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

  • Home
  • SEARCH
  • 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 8967897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:20:52+00:00 2026-06-15T17:20:52+00:00

I trying to auto increment the serial number when row increases and automatically readjust

  • 0

I trying to auto increment the serial number when row increases and automatically readjust the numbering order when a row gets deleted in javascript. For that I am using the following clone method for doing my task. Rest of the thing is working correct except its not increasing the srno because its creating the clone of it. Following is my code for this:

function addCloneRow(obj) {
        if(obj) {       
            var tBody = obj.parentNode.parentNode.parentNode;
            var trTable = tBody.getElementsByTagName("tr")[1];
            var trClone = trTable.cloneNode(true);
            if(trClone) {       
                var txt  = trClone.getElementsByTagName("input");
                var srno  = trClone.getElementsByTagName("span");
                var dd   = trClone.getElementsByTagName("select");

                text = tBody.getElementsByTagName("tr").length;   
                alert(text) //here i am getting the srno in increasing order 
                //I tried something like following but not working                                        
                //var ele = srno.replace(document.createElement("h1"), srno);
                //alert(ele);

                for(var i=0; i<dd.length; i++) {
                    dd[i].options[0].selected=true;
                    var nm = dd[i].name;
                    var nNm = nm.substring((nm.indexOf("_")+1),nm.indexOf("["));
                    dd[i].name = nNm+"[]";
                }
                for(var j=0; j<txt.length; j++) {
                    var nm = txt[j].name;
                    var nNm = nm.substring((nm.indexOf("_")+1),nm.indexOf("["));
                    txt[j].name = nNm+"[]";
                    if(txt[j].type == "hidden"){ 
                        txt[j].value = "0"; 
                    }else if(txt[j].type == "text") {               
                        txt[j].value = "";              
                    }else if(txt[j].type == "checkbox") {               
                        txt[j].checked = false;
                    }
                }

                for(var j=0; j<txt.length; j++) {
                    var nm = txt[j].name;
                    var nNm = nm.substring((nm.indexOf("_")+1),nm.indexOf("["));
                    txt[j].name = nNm+"[]";
                    if(txt[j].type == "hidden"){ 
                        txt[j].value = "0"; 
                    }else if(txt[j].type == "text") {               
                        txt[j].value = "";              
                    }else if(txt[j].type == "checkbox") {               
                        txt[j].checked = false;
                    }
                }
                tBody.insertBefore(trClone,tBody.childNodes[1]);                
            }
        }
    }

Following is my html :

<table id="step_details" style="display:none;">
            <tr>
                <th width="5">#</th>
                <th width="45%">Step details</th>
                <th>Expected Results</th>
                <th width="25">Execution</th>
                <th><img src="gui/themes/default/images/ico_add.gif" onclick="addCloneRow(this);"/></th>
            </tr>

            <tr>
                <td><span>1</span></td>
                <td><textArea name="step_details[]"></textArea></td>
                <td><textArea name="expected_results[]"></textArea></td>
                <td><select onchange="content_modified = true"  name="exec_type[]">
                        <option selected="selected" value="1" label="Manual">Manual</option>
                        <option value="2" label="Automated">Automated</option>
                    </select>
                </td>
                <td><img src="gui/themes/default/images/ico_del.gif" onclick="removeCloneRow(this);"/></td>
            </tr>    
        </table>

I want to change the srno. of span element dynamically after increment and decrement on it.

Need help thanks

  • 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-06-15T17:20:54+00:00Added an answer on June 15, 2026 at 5:20 pm

    I think that what you want is something this:

    var varcharCurrentNumber = trClone.getElementsByTagName("span")[0].innerHTML;
    var nextNumber= eval(varcharCurrentNumber) +1;
    trClone.getElementsByTagName("span")[0].innerHTML = nextNumber;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make an auto increment function that each time user create table
I'm trying to create a hash which stores an auto-increment number for a non-existent
I am trying to auto increment my xml file. I have a form that
Using Postgres, I'm trying to use AUTO_INCREMENT to number my primary key automatically in
I am just trying to get the auto incremented value of a table that
I'm trying to create a table that has a primary key (Department_ID) that auto
I'm trying to set up a model using UUIDs instead of auto-increment. Without bothering
I'm trying to get the auto incremented column of a row. The code will
I am trying to reseed the auto increment value from the current auto increment
I'm trying to fill my array with an auto-increment (listeFormatte.lenght) and it break at

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.