Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > BOOK: Professional JavaScript for Web Developers ISBN: 978-0-7645-7908-0
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Professional JavaScript for Web Developers ISBN: 978-0-7645-7908-0
This is the forum to discuss the Wrox book Professional JavaScript for Web Developers by Nicholas C. Zakas; ISBN: 9780764579080
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional JavaScript for Web Developers ISBN: 978-0-7645-7908-0 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 2nd, 2011, 06:35 AM
Registered User
Points: 79, Level: 1
Points: 79, Level: 1 Points: 79, Level: 1 Points: 79, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jan 2010
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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.


function createhtml(elementname,attr)
//first method
 window['o' + elementname].setAttribute(atr, attr1[1]);  
 //second method                    
 var e=document.getElementById(elementnode)
e. window[atr]= attr1[1]  }  

here window['o' + elementname] is the element to which the attributes needs to be set.
atr is the name of attribute and attr1[1] is the value. To create an attribute dynamically which is in bold as shown in the code above.
here instead of giving

e. style.width= attr1[1]

i want to write
e.'the variable name'=attr1[1]
in both methods that i mentioned in my code null value error occurred.
how to achieve this?

Last edited by ammu86; November 2nd, 2011 at 07:30 AM..
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Display HTML Attributes from XML Attributes rangeshram XSLT 3 March 27th, 2010 01:14 PM
this.attributes.add not working millerthegorilla SharePoint Development 1 June 17th, 2008 03:44 AM
Transform html table to add ids/headers using xsl kapy_kal XSLT 2 February 21st, 2007 10:12 AM
Calling Javascript Function With Attributes.Add OutCaster ASP.NET 1.0 and 1.1 Basics 1 January 27th, 2006 09:53 PM

All times are GMT -4. The time now is 04:21 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.