It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum

How to add attributes to html table using javascript?

How to add attributes to html table using javascript?

Postby ammu on Wed Nov 02, 2011 9:37 am

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:
Code: Select all
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:

Code: Select all
e. style.width= attr1[1]



i want to write
Code: Select all
e.'the variable name'=attr1[1]

how to achieve this?
ammu
 
Posts: 1
Joined: Wed Nov 02, 2011 9:25 am

Who is online

Users browsing this forum: No registered users and 4 guests