troubleshooting Question

set name attribute failing

Avatar of KeithMcElroy
KeithMcElroy asked on
VB ScriptJavaScriptHTML
2 Comments1 Solution252 ViewsLast Modified:
The attached code in a web page is not updating the name attribute.
The old name appears in the alert of outerHTML.
I tried removeAttribute then reassigning and NO name attribute shows.

What am i missing?
function addsplititem(id,idx,tbod,tab)
{

	var tab = GetElement("tblsplit_" + idx)

	var tbod = tab.tBodies[1]

	
	var trow = tbod.rows[tbod.rows.length - 1]

	var clonerow = trow.cloneNode(true);	
	var newtrow= tbod.appendChild(clonerow)
	
	newtrow.setAttribute("subidx", Number(newtrow.getAttribute("subidx")) + 1)
	var tds = newtrow.childNodes 
	for(t=0;t<tds.length;t++)
	{
		var sds = tds[t].childNodes
		for(s=0;s<sds.length;s++)
		{
			if(sds[s].nodeName == "INPUT")
			{
				if(sds[s].getAttribute("autoinc") == "b")
				{

					var arrpieces = sds[s].id.split("_")
					var loc0 = arrpieces[0]
					var loc1 = arrpieces[1]
					var loc2 = arrpieces[2]
					var loc3 = arrpieces[3]
					var loc4 = (Number(arrpieces[4]) + 1).toString()
					locid = loc0 + "_" + loc1 + "_" + loc2 + "_" + loc3 + "_" + loc4
					sds[s].id = locid
					sds[s].removeAttribute("name")
					sds[s].setAttribute("name",  locid)
				alert(sds[s].outerHTML)
				}
			}
		}
		
	}
	//alert(newtrow.outerHTML)
	
}
ASKER CERTIFIED SOLUTION
vr6r

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros