
November 2nd, 2011, 03:44 AM
|
|
Registered User
|
|
Join Date: Nov 2011
Posts: 1
Time spent in forums: 20 m 33 sec
Reputation Power: 0
|
|
|
Need Help Debugging Script/Error in Script - How to add attributes to html table using javascript?
I want to create a html table dynamically using javascript.
here the element name and attributes will be passed to the function as shown below.
Code:
function createhtml(elementname,attr)
{
for(j=0;j<attrs.length;j++)
{
attr1=attr1.split("=")
atr=attr1[0];
//first method
window['o' + elementname].setAttribute(atr, attr1[1]);
//second method
var e=document.getElementById(elementnode)
e. window[atr]= attr1[1] }
}
here i tried several methods to create dynamically an attribute which is in bold in the code above.
instead of giving
Code:
e. style.width= attr1[1]
i want to write e.'the variable name'=attr1[1]
how to achieve this?
|