How to set attributes in dynamically creating table structure using javascript?

Im developing a script for dynamically creating html table structure so that from the input that has been given to the function it will fetch the values one by one and will create the structure. My problem is i want to add attributes to the elements created. sample code attached.


with( window['o' + elementname]){
 for(j=0;j<attrs.length;j++)
 {
 if(attrs[j].indexOf("=")!=-1){
var attr1={}
attr1=attrs[j]
attr1=attr1.split("=")
[B] window[attr1[0]]=attr1[1];[/B]
}
 }}

here the element name will be get from the parameters passed to the function. i want to verify whether the line in bold is correct or not coz the id is not updated in output.