472,337 Members | 1,478 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,337 software developers and data experts.

posting form data from dynamically created form elements


I have a form whose elements are created dynamically on selection, i.e. the form has only text boxes and the number of text boxes depends on the users selection, if user selects 3 then 3 dynamic text boxes are created and if user selects 4 then 4 dynamic text boxes are created and so on. Here is the code I am using to dynamically create the text boxes:

Expand|Select|Wrap|Line Numbers
  1. echo ("<form name='exam' action='exam_2.php' method='POST'>");
  2. for ($j=0;$j<sizeof($namearr);$j++){
  4.     echo ("<tr>");
  5.     echo ("<td>".$namearr[$j]."</td>");
  6.     echo ("<td>");
  7.     echo ("<input type='text' name='element' size='8'>");
  8.     echo ("</td>");
  9. }
  10. echo ("<input type='submit' name='exam_sub' value='submit'>");
  11. echo ("</form>");
My problem is I want to send the form elements to next page i.e. exam_2.php when submit button is clicked, I am using below code on exam_2.php page to get the data of text boxes:

Expand|Select|Wrap|Line Numbers
  1. $element = $_POST['element']; 
  2. echo $element; 
The $element contains nothing, should I treat $element as an array, I need all the values of textboxes, how will I get it.

Any help is greatly appreciated. Please give me some suggestions or coding examples.

With regards,
Sep 26 '09 #1
2 3972
1,654 Expert 1GB
Change line 7 as:
Expand|Select|Wrap|Line Numbers
  1. echo ("<input type='text' name='element[]' size='8'>");
In exam_2.php, see what is being posted with code:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. echo "<pre>";
  3. print_r($_POST);
  4. echo "</pre>";
  5. ?>
Sep 27 '09 #2
Thanks hsriat, its working!!!
Sep 29 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

by: Ittay Dror | last post by:
Hi, As an example, imagine I want to write a page with a form for emailing it to a number of people. In pure HTML, i'd create an initial layout...
by: Will | last post by:
Hi, I have a problem trying to validate dynamically created html form elements using javascript. I have dynamically created a check box using ASP...
by: Nicholas Couch | last post by:
I have a little form with a couple of dynamically generated list boxes. When the user makes a selection from the first box, the second box is...
by: monomaniac21 | last post by:
Hi all Can anyone tell me how to submit a form to update its contents to a db and then from the page the form is submitted to then submit another...
by: assgar | last post by:
Hi I am stuck on a problem. I use 3 scripts(form, function and process). Development on win2003 server. Final server will be linux...
by: guido | last post by:
I've written a user control to add form fields to a aspx page: Private Sub buildFields() 'Label1.Text = "building fields at " &...
by: mitchell | last post by:
hi, i am having problems while uploading a file. i created an input element of file type and appended it to a form. after selecting the file...
by: student4lifer | last post by:
Hello, could someone show me how to make sticky form with dynamically generated form element? for example, if one likes to make the dynamically...
by: Mayan F | last post by:
If you're into that maybe you could help me with another thing I'm upto now: I succeeded in dynamically creating the controls but now I'm trying...
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.