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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:14:21+00:00 2026-06-18T04:14:21+00:00

I made a form where you can add more fields by clicking on a

  • 0

I made a form where you can add more fields by clicking on a button. Everytime you click on a button it makes a new field with a higher number behind it. I do this with jquery and I need to get the highest number with php.
So if I have auto_part1 and auto_part2 I need to get 2 with PHP.

This is my html:

<div id="parts">
    Part
    <input type="text" id="auto_part" name="auto_part" />
                <br />
    Description
    <input type="text" id="auto_description" name="auto_description" />
                <br />
</div>
    <a href="#" id="addField">Add another part</a>

The jQuery function:

$(function() {
var scntDiv = $('#parts');
var i = $('#parts input').size() + -1;

$('#addField').on('click', function() {
    $('<br /><span>Part</span> <input type="text" id="auto_part'+i+'" name="auto_part'+i+'" /><br />').appendTo(scntDiv);
    $('<span>Description</span> <input type="text" id="auto_description'+i+'" name="auto_description'+i+'" /> <br />').appendTo(scntDiv);
    i++;
    return false;
});

$('#remScnt').on('click', function() { 
    if( i > 2 ) {
            $(this).parents('p').remove();
            i--;
    }
    return false;
});
});
  • 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-18T04:14:22+00:00Added an answer on June 18, 2026 at 4:14 am

    Create a hidden input field:

    <input type="hidden" id="row_count" name="row_count" value="">
    

    And onsubmit do:

    $('#row_count').val(i);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I made a form so that users can register their email address for a
Basically I've made a form in Cakephp 2.1 with a jQuery button that appends
I'm setting up a form in which multiple entries can potentially be made (via
I've made a nice form, and a big complicated 'add' function for handling it.
Say that I have made some software (which has both library form and can
I have a form made by Zend Framework that needs a submit button. I
I have made a custom UserControl i Vb.net (windows application). How can I add
I made a form that users can fill out and it checks if the
I made register form where you have to put in all your personal info.
I made the form partial for creating microposts as shown in Listing 10.33 with

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.