CodingIsFun
Programmer
Hi all experts,
I am trying to rename input tags for the purposes of reusing a particular table to create new instances on the same page.
for some reason the following code(alert(table_content.innerHTML) shows no changes, but when the alert in the for loop is uncommented it appears to be changing the value:
function addLineSubSection(divName,table_content){
var randomnumber=Math.floor(Math.random()*9999)
var output = document.getElementById(divName).innerHTML ;
for(i = 0; i < table_content.getElementsByTagName("input").length; i++) {
table_content.getElementsByTagName("input").setAttribute("name",table_content.getElementsByTagName("input").getAttribute("name") + "_" + randomnumber);
//alert(table_content.getElementsByTagName("input").getAttribute("name"));
}
// //text += spanTag.childNodes.nodeValue;
alert(table_content.innerHTML);
output += table_content.innerHTML;
document.getElementById(divName).innerHTML = output;
}
thanks in advance
I am trying to rename input tags for the purposes of reusing a particular table to create new instances on the same page.
for some reason the following code(alert(table_content.innerHTML) shows no changes, but when the alert in the for loop is uncommented it appears to be changing the value:
function addLineSubSection(divName,table_content){
var randomnumber=Math.floor(Math.random()*9999)
var output = document.getElementById(divName).innerHTML ;
for(i = 0; i < table_content.getElementsByTagName("input").length; i++) {
table_content.getElementsByTagName("input").setAttribute("name",table_content.getElementsByTagName("input").getAttribute("name") + "_" + randomnumber);
//alert(table_content.getElementsByTagName("input").getAttribute("name"));
}
// //text += spanTag.childNodes.nodeValue;
alert(table_content.innerHTML);
output += table_content.innerHTML;
document.getElementById(divName).innerHTML = output;
}
thanks in advance