Generating Fields On the Fly

Reply

Join Date: May 2008
Posts: 43
Reputation: yasmena is an unknown quantity at this point 
Solved Threads: 0
yasmena yasmena is offline Offline
Light Poster

Generating Fields On the Fly

 
0
  #1
Oct 8th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 1,072
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: Generating Fields On the Fly

 
0
  #2
Oct 8th, 2008
you mean dynamic text box generation...
or
what do you mean by fields here?
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: May 2008
Posts: 43
Reputation: yasmena is an unknown quantity at this point 
Solved Threads: 0
yasmena yasmena is offline Offline
Light Poster

Re: Generating Fields On the Fly

 
0
  #3
Oct 8th, 2008
yeah thats what i mean dynamic text box generation
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 1,072
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: Generating Fields On the Fly

 
0
  #4
Oct 8th, 2008
hello..
try this code:
  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 Chepuru; Oct 8th, 2008 at 10:20 am.
Be intelligent, But Don't try to cheat.. Be innocent But Don't get cheated..
Reply With Quote Quick reply to this message  
Reply

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



Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC