943,815 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 530
  • PHP RSS
Oct 8th, 2008
0

Generating Fields On the Fly

Expand Post »
im asking the user to enter the number of fields he want to generate and i need to take this number and generate him the fields when he click Submit

can anyone Help Me
Reputation Points: 10
Solved Threads: 0
Light Poster
yasmena is offline Offline
45 posts
since May 2008
Oct 8th, 2008
0

Re: Generating Fields On the Fly

you mean dynamic text box generation...
or
what do you mean by fields here?
Reputation Points: 137
Solved Threads: 162
Posting Virtuoso
Shanti C is offline Offline
1,641 posts
since Jul 2008
Oct 8th, 2008
0

Re: Generating Fields On the Fly

yeah thats what i mean dynamic text box generation
Reputation Points: 10
Solved Threads: 0
Light Poster
yasmena is offline Offline
45 posts
since May 2008
Oct 8th, 2008
0

Re: Generating Fields On the Fly

hello..
try this code:
html Syntax (Toggle Plain Text)
  1. <!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
  2. <html>
  3. <head>
  4. <title>Third Santor</title>
  5. <script>
  6. function generate(){
  7. var myDiv = document.getElementById('someid');
  8. var objTextArea = document.getElementById('mem1');
  9.  
  10. var list = objTextArea.value.split('\n');
  11.  
  12.  
  13. var tbody = document.createElement('tbody');
  14.  
  15. for(var i=0; i<list.length; i++){
  16.  
  17. var cell1 = document.createElement('td');
  18. var label = document.createTextNode(list[i]);
  19. cell1.appendChild(label);
  20.  
  21. var cell2 = document.createElement('td');
  22. var textbox = document.createElement('input');
  23. textbox.type = 'text';
  24. textbox.id = list[i];
  25. cell1.appendChild(textbox);
  26.  
  27. var row = document.createElement('tr');
  28. row.appendChild(cell1);
  29. row.appendChild(cell2);
  30.  
  31. tbody.appendChild(row);
  32. }
  33.  
  34. var table = document.createElement('table');
  35. table.border = 1;
  36. table.appendChild(tbody);
  37.  
  38. /* var submit = document.createElement('input');
  39. submit.type = 'submit';
  40. submit.value = 'Submit';
  41. */
  42. myDiv.appendChild(table);
  43. myDiv.appendChild(submit);
  44. }
  45. </script>
  46. </head>
  47. <body topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">
  48. <form name="frm1" method="post" action="" onsubmit="return ">
  49. <textarea name="mem1" id="mem1" rows="10" cols="30"></textarea>
  50. <input type="button" value="Generate" onclick="generate();">
  51. </form>
  52. <DIV id="someid"></DIV>
  53. </body>
  54. </html>
and also check:
http://www.daniweb.com/forums/thread135356.html
Last edited by Shanti C; Oct 8th, 2008 at 10:20 am.
Reputation Points: 137
Solved Threads: 162
Posting Virtuoso
Shanti C is offline Offline
1,641 posts
since Jul 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: Multiple files Upload plz HelP
Next Thread in PHP Forum Timeline: Need the help of a programer





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


Follow us on Twitter


© 2011 DaniWeb® LLC