problem to create input text continiously?

Reply

Join Date: Apr 2008
Posts: 296
Reputation: Aamit has a little shameless behaviour in the past 
Solved Threads: 11
Aamit Aamit is offline Offline
Posting Whiz in Training

problem to create input text continiously?

 
0
  #1
Sep 8th, 2009
Hi,
I am writing code to create new text filed dynamically.
But after create 2 or 3 it stops.
Not creating continuously.

How to solve this??

  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  2. "http://www.w3.org/TR/html4/loose.dtd">
  3. <html>
  4. <head>
  5. <title>Untitled Document</title>
  6. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  7. <SCRIPT language="javascript">
  8.  
  9. function GenerateRow(rowid){
  10.  
  11.  
  12. str = '<tr>';
  13. str = str + '<td width="7" align="left" valign="top"><img src="images/cor-topLeft.gif" width="7" height="6" alt=""/></td>';
  14. str = str + '<td width="894"></td>';
  15. str = str + '<td width="8" align="right" valign="top"><img src="images/cor-topRight.gif" width="7" height="6" alt=""/></td>';
  16. str = str + '</tr>';
  17. str = str + '<tr>';
  18. str = str + ' <td></td>';
  19. str = str + ' <td class="formText">';
  20. str = str + ' <input name="textfield10" type="text" class="inputText" id="textfield10" size="20" />';
  21. str = str + ' @yourdomain.com points to';
  22. str = str + ' <select name="select3" class="dropDown" id="select3">';
  23. str = str + ' <option>Select</option>';
  24. str = str + ' <option selected="selected">miles</option>';
  25. str = str + ' </select>@yourdomain.com</td>';
  26.  
  27. str = str + '<td></td>';
  28. str = str + '</tr>';
  29. str = str + '<tr>';
  30. str = str + ' <td align="left" valign="bottom"><img src="images/cor-botLeft.gif" width="7" height="6" alt=""/></td>';
  31. str = str + ' <td></td>';
  32. str = str + ' <td align="right" valign="bottom"><img src="images/cor-botRight.gif" width="7" height="6" alt=""/></td>';
  33. str = str + ' </tr>';
  34.  
  35. return str;
  36. }
  37.  
  38.  
  39. function AddLastRow(){
  40.  
  41. var htm = document.getElementById("service_table").innerHTML;
  42.  
  43. var tbl = '<table border="0" cellpadding="0" cellspacing="0" bgcolor="#d2e8fd" width="909" id="tbl1">';
  44.  
  45.  
  46. var tbl;
  47. var tbl2="";
  48.  
  49. if(htm ==""){
  50. tbl2 = tbl2 + GenerateRow(1);
  51.  
  52. }
  53. else{
  54. tbl2 = "";
  55. var obj = document.getElementById("tbl1")
  56. var trobj = obj.getElementsByTagName("tr");
  57.  
  58. for(i=0;i<trobj.length;i++)
  59. {
  60. tbl2 = tbl2 + "<tr bgcolor='#d2e8fd'>"
  61. tbl2 = tbl2 + trobj[i].innerHTML
  62. tbl2 = tbl2 + "</tr>"
  63. }
  64. //tbl = tbl+tbl2;
  65. len = trobj.length;
  66. len = len +1;
  67.  
  68. tbl2 = tbl2 + GenerateRow()
  69.  
  70. len = len +1;
  71.  
  72. }
  73. tbl = tbl + tbl2 + "</table>";
  74. //alert(tbl)
  75. document.getElementById("service_table").innerHTML=tbl;
  76. }
  77. </SCRIPT>
  78. </head>
  79.  
  80. <body>
  81. <table width="909" border="0" cellpadding="0" cellspacing="0" bgcolor="#d2e8fd" id="tbl1">
  82. <tr>
  83. <td width="7" align="left" valign="top"><img src="images/cor-topLeft.gif" width="7" height="6" alt=""/></td>
  84. <td width="894">&nbsp;</td>
  85. <td width="8" align="right" valign="top"><img src="images/cor-topRight.gif" width="7" height="6" alt=""/></td>
  86. </tr>
  87. <tr>
  88. <td>&nbsp;</td>
  89. <td class="formText">
  90. <input name="textfield10" type="text" class="inputText" id="textfield10" size="20" />
  91. @yourdomain.com points to
  92. <select name="select3" class="dropDown" id="select3">
  93. <option>Select</option>
  94. <option selected="selected">miles</option>
  95. </select>
  96. @yourdomain.com</td>
  97. <td>&nbsp;</td>
  98. </tr>
  99. <tr>
  100. <td align="left" valign="bottom"><img src="images/cor-botLeft.gif" width="7" height="6" alt=""/></td>
  101. <td>&nbsp;</td>
  102. <td align="right" valign="bottom"><img src="images/cor-botRight.gif" width="7" height="6" alt=""/></td>
  103. </tr>
  104. </table>
  105. <div id='service_table'></div>
  106.  
  107. <table width="924" border="0" cellspacing="0" cellpadding="0">
  108. <tr>
  109. <td width="754">&nbsp;</td>
  110. <td width="108" class="addUser"><strong>Add email alias</strong></td>
  111. <td width="62">
  112. <img src="images/plus.gif" alt="Add User" onclick="AddLastRow();"/></td>
  113.  
  114. </tr>
  115. </table>
  116. </body>
  117. </html>
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 807
Reputation: darkagn has a spectacular aura about darkagn has a spectacular aura about darkagn has a spectacular aura about 
Solved Threads: 110
darkagn's Avatar
darkagn darkagn is offline Offline
Practically a Posting Shark

Re: problem to create input text continiously?

 
0
  #2
Sep 8th, 2009
I must admit that javascript is not my strong suit, but I will try to help. The line
  1. tbl2 = tbl2 + GenerateRow()
What happens in javascript if you call a function without the parameter in the method signature? Also you appear to be missing several ;'s to end your statements, not sure what effect this might have?
There are no stupid questions, only those too stupid to ask for help.
echo is a web developer's best friend.
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: 319 | Replies: 1
Thread Tools Search this Thread



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

©2003 - 2009 DaniWeb® LLC