hi
I’m trying to add html controls dynamically.
and I successful in that using clone method.
But I lost my way …..
I confused how to retrieve the values from the controls which I had cloned.
Below is the simplified code i had done.
Please help me in retrieving the values. I’m new in using dom objects?
[code]
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml” xml:lang=”en” lang=”en”>
<head>
<title></title>
<script language=”javascript” type=”text/javascript”>
function Add(id){
var table=document.getElementById(id);
var clone=table.getElementsByTagName(‘TBODY’)[0].cloneNode(true);
table.appendChild(clone);
counter++;
}
</script>
</head>
<body>
<form name=”form1″ method=”post” action=””>
<input type=”button” name=”” value=”Add” onclick=”Add(‘tst’);”/>
<input type=”button” name=”getValues” value=”getValues” onClick=”getValue()”>
<table id=”tst” >
<tbody>
<tr>
<td colspan=”7″ bgcolor=”#EEEEEE”><b>Residential Address Details</b></td>
</tr>
<tr>
<td colspan=”1″> Address Line 1 </td>
<td colspan=”6″>
<input type=”text” style=”width: 300″ class=”inputsubmit” name=”address_line_1″ id=”address_line_1″ onChange=”saveValues1(this.value)”>
</td>
</tr>
<tr>
<td colspan=”1″> Address Line 2 </td>
<td colspan=”6″>
<input type=”text” style=”width: 300″ class=”inputsubmit” name=”address_line_2″ id=”address_line_2″ onChange=”saveValues2(this.value)”>
</td>
</tr>
<tr>
<td colspan=”1″> Country of Residence </td>
<td colspan=”6″>
<input type=”text” class=”inputsubmit” name=”country_residence” style=”width:35%” onChange=”javascript:this.value=this.value.toUpperCase();” id=”country_residence”/>
Residency Type
<select id=”residence_perm_temp” name=”residence_perm_temp” class=”inputsubmit2″>
<option selected value=””>Permanent</option>
<option value=”temporary”>Temporary</option>
</select>
</td>
</tr>
</tbody>
</table>
</form>
</body>
</html>