dynamic form generation in PHP

Reply

Join Date: Jun 2008
Posts: 46
Reputation: akshit is an unknown quantity at this point 
Solved Threads: 0
akshit akshit is offline Offline
Light Poster

dynamic form generation in PHP

 
0
  #1
Jul 19th, 2008
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...
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 1,076
Reputation: Shanti Chepuru is on a distinguished road 
Solved Threads: 98
Shanti Chepuru's Avatar
Shanti Chepuru Shanti Chepuru is offline Offline
Veteran Poster

Re: dynamic form generation in PHP

 
0
  #2
Jul 19th, 2008
this is one type:
  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>
Be intelligent, But Don't try to cheat.. Be innocent But Don't get cheated..
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 1,076
Reputation: Shanti Chepuru is on a distinguished road 
Solved Threads: 98
Shanti Chepuru's Avatar
Shanti Chepuru Shanti Chepuru is offline Offline
Veteran Poster

Re: dynamic form generation in PHP

 
0
  #3
Jul 19th, 2008
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.


  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>
Be intelligent, But Don't try to cheat.. Be innocent But Don't get cheated..
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 46
Reputation: akshit is an unknown quantity at this point 
Solved Threads: 0
akshit akshit is offline Offline
Light Poster

Re: dynamic form generation in PHP

 
0
  #4
Jul 19th, 2008
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..
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 1399 | Replies: 3
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC