473,574 Members | 3,010 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

posting form data from dynamically created form elements

59 New Member
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 4042
hsriat
1,654 Recognized Expert Top Contributor
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
gubbachchi
59 New Member
Thanks hsriat, its working!!!
Sep 29 '09 #3

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

Similar topics

0
1401
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 button and an 'add another email' button, which will dynamically (and on the client side) create another text box. How do I implement such a page...
1
3181
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 a unique ID using the primary key from a db table. e.g "chk" + "1" for record 1 and "chk" + "2" for record 2 etc. This means each box is called chk1...
27
4706
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 box, I concatenate the selections from the two boxes and add the string to a list at the top of the form, using createElement and appendChild. The...
5
1946
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 site such as paypal? At the moment im having to have users submit the form and then click a button on successful submission to take them through...
4
2701
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 multiple dynamic rows with chechboxs, input box for units of service, description of the service and each row has its own dropdown list of unit fees...
3
5835
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() themeIDField.ID = "theme_id" themeNamePlaceholder.Controls.Add(themeIDField) End sub ....and call this at page_load. I now need to get the name value pairs...
12
2393
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 again need to select the file. and it works in the second attempt i cant figure out why its happening please help here is the code
9
2772
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 retains the value of the previously submitted value. How would one do that? TIA. I was thinking something along this line but not sure it's the...
1
2211
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 be linked to Me.Subform). But I can't find a way to refer to the form using a form name String parameter (subformSource in the code below). All the...
0
7805
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8052
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8098
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6452
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5620
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5300
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3740
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1339
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1060
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.