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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:14:12+00:00 2026-05-23T00:14:12+00:00

i want to post dynamically generated multiple text box using php by foreach loop.

  • 0

i want to post dynamically generated multiple text box using php by foreach loop.
for instance i m working on question bank and for post multiple answer from php.
here is my code that dynamically generated textbox but now i donot know how to post value of generated textbox thru foreach loop.

$("#questionbank").live('click',function(){
    var mydata = '<div id="questionbank-content" class="page">';
    mydata += '<div class="question"><div class="Label">Question</div><div class="textarea"><textarea id="question" rows="3" cols="30"></textarea></div></div><div class="answer"><div class="Label">Answer</div><div class="textarea"><textarea id="answer" rows="3" cols="30"></textarea></div><div class="option"><input id="a" name="answers" type="radio"></div><span id="add">Add</span>';
    var i=1;
    $('#add').live('click',function(){
         j=i++;
         $(this).after('<div class="Label">Answer</div><div class="textarea"><textarea id="answer + '+ j +'" rows="3" cols="30"></textarea></div><div class="option"><input id="a + '+ j +'" name="answers" type="radio"></div><span id="add">Add</span>');

        //$(this).after('<input id="'+ j +'" type="text" value="'+ j +'"/><span id="add">Add</span>');
        $(this).remove(); 
    });
    mydata += '</div></div>';
    $("#leftcontainer").html(mydata);

});
  • 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-23T00:14:13+00:00Added an answer on May 23, 2026 at 12:14 am

    Consider the following HTML

    <div id="start">Start</div>
    
    <div id="container">
    
    </div>
    

    I guess you want to post data from each value of the textbox/textarea by $.post() or $.ajax()

    var i=1;
    $('#start').one('click',function(){
        j=i++;
       $('#container').append('<input id="answer'+ j +'" type="text" value=""/><span id="add">Add</span>');
        $('#container').after('<div id="submit">Submit</div');
    });
    
    $('#add').live('click',function(){
         j=i++;
        $(this).after('<input id="answer'+ j +'" type="text" value=""/><span id="add">Add</span>');
        $(this).next().next().after('');
        $(this).remove(); 
    });
    
    $('#submit').live('click',function(){
        var x = $('#container > input');
        var qstring='op=insertquestion'; //additional para if u want to pass any
        $.each(x,function(index,value){
            var id = $(this).attr('id');
            var data = $(this).val();
            qstring += '&'+id+'='+data+'';
        });
        $('#start').before(qstring + '<br/>');
    });
    

    After you get the variable qstring just post the string using $.post() method.

    Example on JSFIDDLE.net

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

Sidebar

Related Questions

I want to POST an URL using CURL and php. There is a big
I have a winForms NET3.5SP1 app, and want to POST data to a PHP
Has anyone ever modified the post-new.php file in their WordPress installation? I want to
I have multiple dynamically generated buttons with a class name of .button. Each of
I using jquery's $.post to pull information from a database dynamically. This works fine
I have a page that contains dynamically generated Dropdown List controls and I want
I'm using the Facebook API Graph (C# & ASP.NET) to try to dynamically post
I want to do an HTTP POST that looks like an HMTL form posted
I want to use HTTP GET and POST commands to retrieve URLs from a
I want to salt a hashed username and password (submitted via http POST) in

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.