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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:54:28+00:00 2026-06-05T12:54:28+00:00

I am using jQuery to create as many input textboxes as the user needs

  • 0

I am using jQuery to create as many input textboxes as the user needs like so:

<script type="text/javascript">
$(document).ready(function() {
$('#names').on({
    blur: function() {
        var name = $("<p><input class='input' type='text' /></p>")
        var nullFields = 0;
        $(this).closest('div#names').find('input.input').each(function(){
            if($(this).val() == ""){
                nullFields++;
            }
        });
        console.log(nullFields);
        if(nullFields <= 1){
         $('#names').append(name.fadeIn(500));
        }
    }
}, 'input');
 });
</script>

Inserting a static textbox into a database isn’t a problem using $_POST['blah'] andmysql_query("INSERT INTO ..."), but how do I insert the values of the dynamically created textboxes? I know I’ll have to give the textboxes different names as they’re created and I presume the MySQL query will be by way of some sort of loop.

EDIT

The website in question is here, specifically at step 4. As mentioned above, step 3 was quite straightforward.

  • 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-05T12:54:31+00:00Added an answer on June 5, 2026 at 12:54 pm

    This is an example to get you started, not the complete solution.
    You create an array for the names then have the php insert each array item

    var currentArrayNum = 1;    
    $('#someClickable').click(function(){
    
            $('#td').append('<input name="arrayName['+currentArrayNum+']" value="" />');
            currentArrayNum += 1;
        });
    

    php:

    foreach ($_POST as $key){
            if (is_array($key)){
                    foreach ($key as $key2 => $value){
                    //$key2 will equal arrayName[currentArrayNum]
                   //$value will equal the user input for the text field
    do some stuff
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I create one table by using jquery : <div class=productlist style=float:left; id=productlist> <script type=text/javascript
I need to create the equivalent of jQuery's ready event without using jQuery. It
I'm using jQuery tabs to create a unique user interface for a project I'm
I have a form which allows the user to create extra rows using JQuery
I am using jquery to create a custom dropdown with the code below. I
I am using jquery to create two sets of tabs on a page. The
I am using jQuery mobile to create the following page. http://ielts.progmic.com/iOS/college.php?title=Royal+College+Of+Arts In the link
I'm using jQuery UI to create a button to a given html element. I'm
I'm using jQuery UI to create 6 sliders with the same options (survey). I
I'm using JQuery UI to create a tab, and I want to the contents

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.