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

Hi,

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++){
  3.  
  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,
gubbachchi
Sep 26 '09 #1
2 3972
hsriat
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

0
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...
1
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...
27
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...
5
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...
4
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...
3
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 " &...
12
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...
9
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...
1
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...
0
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...
0
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...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
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...
0
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...
0
jalbright99669
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...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
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. ...
0
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.