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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:41:12+00:00 2026-06-11T06:41:12+00:00

I have a script add rows to the table with textfields everytime i click

  • 0

I have a script add rows to the table with textfields
everytime i click add row:

<script language = "javascript">

var x = 0;

function addRow(){

    var tbody = document.getElementById(tabID).getElementsByTagName("tbody")[0];
    var row = document.createElement("tr")
    var data1 = document.createElement("td")    
    var data2 = document.createElement("td") 

    var element = document.createElement("input");
    element.setAttribute("type", type);
    element.setAttribute("name", type);
    element.setAttribute("id", "Name"+x);
    element.setAttribute("style","width:95px");

    var element1 = document.createElement("input");
    element1.setAttribute("type", type);
    element1.setAttribute("name", type);
    element1.setAttribute("id", "Address"+x);
    element1.setAttribute("style","width:95px");

    var foo = document.tbody;

    data1.appendChild(element)
    data2.appendChild(element1)

    row.appendChild(data1)
    row.appendChild(data2)
    tbody.appendChild(row)

    x++;
}
</script>

How can I pass to php the value of my variable x after submitting, so I can count how many loop should I do?

  • 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-11T06:41:15+00:00Added an answer on June 11, 2026 at 6:41 am

    You need to create an input hidden field inside your form and initialize it with the value of the counter . you can use javascript as follows

     var input = document.createElement("input");
     input.setAttribute("type", "hidden");
     input.setAttribute("name", "counter");
     input.setAttribute("value", x);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this script on my html page: <script language='javascript'>parent.resizeTo(550,510);</script> I'd like to add
I have a HTML table which I add items to from javascript on an
I have a table which has a button to Add Rows. This button adds
I am having a little problem here. I have a <script language =JavaScript runat=server>
I have a PHP script that generates table rows with hidden input tags that
I have a table and I want from user add rows which who want.
I have a table and I had to add a migration script to add
I have a PHP script that inserts rows into a table based on selected
i have a simple html table where i want to delete and add rows
I am trying to insert rows into an html table with javascript. I have

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.