473,322 Members | 1,347 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 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 4030
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 of one text box (for entering an email), a submit...
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 for each record in a recordset and have given each...
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 refreshed. When they make a selection from the second...
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 form which is the payment processing data for a...
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 Apache,Mysql and PHP is being used. The form displays...
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 " & System.DateTime.Now() Dim themeIDField As New TextBox()...
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 when i click on submit the form becomes blank and i...
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 generated check box (and its name) 'sticky' that...
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 to dynamically create a form for these controls(to...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.