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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:28:46+00:00 2026-05-20T10:28:46+00:00

So I have a script that makes dynamic form content and each input has

  • 0

So I have a script that makes dynamic form content and each input has a name of “field-1”, “field-2”, etc. up until the last input is created by the script.

How can I save the form made to the database?

I only know how to do this in a traditional way where you make like 5 static inputs and give them static names and ids then use the either post or get go formulate the mysql_query.

But in my case, the inputs can range from 3 – 200 inputs. and each have a similar name/id of “field+num++”

My html code:

<form id="myForm">

My JS code that will append to my HTML form:

var $int = $('div.int');
$int.html(function(i, html) {
    return html.replace(/(\d+)(.+)/,function(str,s1,s2){
        var text = s2.split('.');
        var text2 = text[1].split('-');
        var text3 = text2[1].split(' ');
        return '<input class="r" name="scene-"' + s1 + ' value="'+ s1.replace(/^\s*/, '').replace(/\s*$/, '') +'" />' +
        '<input class="r" name="int_ext-"' + s1 + ' value="'+ text[0].replace(/^\s*/, '').replace(/\s*$/, '') +'" />' +
        '<input class="r" name="scene_desct-"' + s1 + ' value="'+ text2[0].replace(/^\s*/, '').replace(/\s*$/, '') +'" />' +
        '<input class="r" name="day_night-"' + s1 + ' value="'+ text3[1].replace(/^\s*/, '').replace(/\s*$/, '') +'" />';
    });
});

My HTML code:

<input type="submit" value="Submit" />
</form>

a sample output is:

<input type="text" class="r" name="scene-1" value="1" />
<input type="text" class="r" name="int_ext-1" value="INT" />
<input type="text" class="r" name="scene_desct-1" value="Bedroom" />
<input type="text" class="r" name="day_night-1" value="DAY" />

<input type="text" class="r" name="scene-2" value="2" />
<input type="text" class="r" name="int_ext-2" value="EXT" />
<input type="text" class="r" name="scene_desct-2" value="Outside" />
<input type="text" class="r" name="day_night-2" value="DAY" />

<input type="text" class="r" name="scene-3" value="3" />
<input type="text" class="r" name="int_ext-3" value="INT" />
<input type="text" class="r" name="scene_desct-3" value="Bedroom" />
<input type="text" class="r" name="day_night-3" value="DAY" />

<input type="text" class="r" name="scene-4" value="4" />
<input type="text" class="r" name="int_ext-4" value="EXT" />
<input type="text" class="r" name="scene_desct-4" value="Bedroom" />
<input type="text" class="r" name="day_night-4" value="NIGHT" />

...

more are created on the fly with the script, this can make like 300 sets of these 4 inputs

then I would like to do something like

mysql_query("INSERT INTO `table` (`scene_num`, `int_ext`, `scene_desct`, `day_night`) VALUES ('{$scene}', '{$int_ext}', '{$scene_desct}', '{$day_night}')");
  • 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-20T10:28:47+00:00Added an answer on May 20, 2026 at 10:28 am

    I understand that, you have a script that creates input fields with names and you want to post all fields to server. You can use jQuery’s ajax post method. Check the code.

    $.ajax({
        type: 'POST', // we will post something
        dataType: 'json', // and we want to catch the server response as json
        url: 'yourPostUrl', // write your post url here
        data: $('#myForm').serialize(), // give an id to your form and serialize it. this will prepeare the form fields to post like &field1=lol&field2=lollol ...
        success: function(data) { // data will give you server request as json
            // do your stuff in here, for an example show an alert, says everyting is OK
            alert(data.message); // consider your reply has a message 
        },
        failure: function (data) {
            // handle your Ajax request's failure in here
            alert('Please try again');
        }
    })
    

    I think, this will use for you.

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

Sidebar

Related Questions

I have a script that parses the filenames of TV episodes (show.name.s01e02.avi for example),
I have a script that takes a table name and generates a control file
I have a form containing some dynamic elements. These are basically text input boxes
I have a script that forces a download and I make a call to
I have a complex command that I'd like to make a shell/bash script of.
I have a script that retrieves objects from a remote server through an Ajax
I have a script that checks responses from HTTP servers using the PEAR HTTP
I have a script that renders graphs in gnuplot. The graphs all end up
I have a script that works fine on my test server (using IIS6). The
I have a script that successfully encrypts a credit card. I need it 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.