943,752 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 2735
  • PHP RSS
Jul 19th, 2008
0

dynamic form generation in PHP

Expand Post »
hi guys.

i require some assistance of yours again.

what i want is this:

there is a form (say on page xyz.php) in which i have , say, 5 text-fields.
but i also hav a button. upon clicking whihc, i want another text-field to appear.

i do now want to use hidden fields as that would limit the number of EXTRA fields to a predefined value.

besides, i also hav to access the data [in each of the 5 fields as well as ALL the extra fields] on the "action page" of xyz.php (say abc.php)

javascript code shud do it but i m not able to figure it out....

could somebody pls help me wid -

1. dynamic text-box generation
2. accessing these fields on abc.php for insertion into MySQL database.

thx a lot...
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
akshit is offline Offline
46 posts
since Jun 2008
Jul 19th, 2008
0

Re: dynamic form generation in PHP

this is one type:
php Syntax (Toggle Plain Text)
  1.  
  2. <script>
  3. function Add()
  4. {
  5. </script>
  6. <td width="300" ><input type="text" name="txt_prodid[]" class="border" size="25" /></td>
  7. <td width="200" colspan="2"><input name="txt_proddescription[]" type="text" class="border" size="36" /></td>
  8.  
  9. <td width="200"><input type="text" name="txt_prodquantity[]" size="20" class="border" /></td>
  10. <script>
  11. }
  12. </script>
  13.  
  14.  
  15.  
  16. <form name="pr_form" action="pr_add.php" method="post" onSubmit="return validateForm();">
  17.  
  18. <tr width="508" align="center">
  19.  
  20. <td colspan="2" align="right"><input name="Product" type="submit" value="Add Product" class="buttonSubmitMedium" onClick="Add();"></td>
Reputation Points: 137
Solved Threads: 162
Posting Virtuoso
Shanti C is offline Offline
1,641 posts
since Jul 2008
Jul 19th, 2008
0

Re: dynamic form generation in PHP

The way I understand it, you want to have new textboxes appear due to an onClick event attached to a button. If that is incorrect, please clarify the post a bit.
To proceed with my understanding, let me preface: You will not need PHP to accomplish this task. A little CSS and Javascript will do the trick.


html Syntax (Toggle Plain Text)
  1. <html>
  2. <!-- CSS Declaration -->
  3. <head>
  4. <style type="text/css">
  5.  
  6. /* Sets class for the text box with a hidden property */
  7. .hide {
  8. display:none;
  9. }
  10.  
  11. /* Sets class for the text box with a visible property */
  12. .show {
  13. display:block;
  14. }
  15.  
  16. </style>
  17. </head>
  18.  
  19. <body>
  20.  
  21. <input type="button" value="Show" onclick="document.getElementById('MyBox').className='show';" />
  22. <input type="button" value="Hide" onclick="document.getElementById('MyBox').className='hide';" />
  23.  
  24. <br />
  25. <br />
  26.  
  27. <!-- Hide and Show this DIV with the buttons above -->
  28. <div id="MyBox" class="hide">
  29. <input type="text" name="TextBoxName" />
  30. </div>
  31. </body>
  32. </html>
Reputation Points: 137
Solved Threads: 162
Posting Virtuoso
Shanti C is offline Offline
1,641 posts
since Jul 2008
Jul 19th, 2008
0

Re: dynamic form generation in PHP

an ONCLICK-event based field-generation is exactly what i want.

thx 4 ur reply.

i shall try it in my app and get bak 2 u.

thx again.

thx a lot..
Reputation Points: 10
Solved Threads: 0
Light Poster
akshit is offline Offline
46 posts
since Jun 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: security using cookies/session variables
Next Thread in PHP Forum Timeline: how to attach more than one files with php? can anyone help me?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC