0

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??

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<SCRIPT language="javascript">

function GenerateRow(rowid){

								
	str = '<tr>';
	str = str + '<td width="7" align="left" valign="top"><img src="images/cor-topLeft.gif" width="7" height="6" alt=""/></td>';	
	str = str + '<td width="894"></td>';
	str = str + '<td width="8" align="right" valign="top"><img src="images/cor-topRight.gif" width="7" height="6" alt=""/></td>';
	str = str + '</tr>';
	str = str + '<tr>';
	str = str + '	<td></td>';
	str = str + '	<td class="formText">';
	str = str + '		<input name="textfield10" type="text" class="inputText" id="textfield10" size="20" />';
	str = str + '		@yourdomain.com points to';
	str = str + '		<select name="select3" class="dropDown" id="select3">';
	str = str + '			<option>Select</option>';
	str = str + '			<option selected="selected">miles</option>';
	str = str + '			</select>@yourdomain.com</td>';             
	
	str = str + '<td></td>';
	str = str + '</tr>';
	str = str + '<tr>';
	str = str + '	<td align="left" valign="bottom"><img src="images/cor-botLeft.gif" width="7" height="6" alt=""/></td>';
	str = str + '	<td></td>';
	str = str + '	 <td align="right" valign="bottom"><img src="images/cor-botRight.gif" width="7" height="6" alt=""/></td>';
	str = str + '	</tr>';
	
	return str;
}


function AddLastRow(){

	var htm = document.getElementById("service_table").innerHTML;
	
	var tbl = '<table border="0" cellpadding="0" cellspacing="0" bgcolor="#d2e8fd" width="909" id="tbl1">';
	

	var tbl;
	var tbl2="";
	
	if(htm ==""){
		tbl2 = tbl2 + GenerateRow(1);					
		
	}
	else{
		tbl2 = "";
		var obj = document.getElementById("tbl1")
		var trobj = obj.getElementsByTagName("tr");
		
		for(i=0;i<trobj.length;i++)
		{
			tbl2 = tbl2 + "<tr bgcolor='#d2e8fd'>"
			tbl2 = tbl2 + trobj[i].innerHTML
			tbl2 = tbl2 + "</tr>"
		}
		//tbl = tbl+tbl2;
		len = trobj.length;
		len = len +1;
		
		tbl2 = tbl2 + GenerateRow()
		
		len = len +1;
		
	    }
	tbl = tbl +  tbl2 +  "</table>";
	//alert(tbl)
	document.getElementById("service_table").innerHTML=tbl;
}
  </SCRIPT>
</head>

<body>
<table width="909" border="0" cellpadding="0" cellspacing="0" bgcolor="#d2e8fd" id="tbl1">
		<tr>
			<td width="7" align="left" valign="top"><img src="images/cor-topLeft.gif" width="7" height="6" alt=""/></td>
			<td width="894">&nbsp;</td>
			<td width="8" align="right" valign="top"><img src="images/cor-topRight.gif" width="7" height="6" alt=""/></td>
		</tr>
		<tr>
			<td>&nbsp;</td>
			<td class="formText">
			<input name="textfield10" type="text" class="inputText" id="textfield10" size="20" />
			@yourdomain.com points to 
				<select name="select3" class="dropDown" id="select3">
					<option>Select</option>
					<option selected="selected">miles</option>
				</select>                
			@yourdomain.com</td>
			<td>&nbsp;</td>
		</tr>
		<tr>
		  <td align="left" valign="bottom"><img src="images/cor-botLeft.gif" width="7" height="6" alt=""/></td>
		  <td>&nbsp;</td>
		  <td align="right" valign="bottom"><img src="images/cor-botRight.gif" width="7" height="6" alt=""/></td>
		</tr>
	</table>
	<div id='service_table'></div>
	
	<table width="924" border="0" cellspacing="0" cellpadding="0">
		<tr>
			<td width="754">&nbsp;</td>
			<td width="108" class="addUser"><strong>Add email alias</strong></td>
			<td width="62">
			<img src="images/plus.gif" alt="Add User" onclick="AddLastRow();"/></td>
			
		</tr>
	</table>
</body>
</html>
2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by darkagn
0

I must admit that javascript is not my strong suit, but I will try to help. The line

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?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.