473,788 Members | 2,759 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem setting attriibutes in JS

I'm trying to mess about with a table using javascript. I'm deleting the
current row then adding a new row and adding a couple of columns. I then
want to add either a style attribute and add a border to the bottom of one
of the cells or add a class attribute and set it up in the stylesheet.
Problem is, when I try to use the setAttribute it doesn't do anything. In
fact when I try and set any attribute of cellLeft or cellRight such as
bgcolor=red; it does nothing. It sets the width ok though!

Can anyone spot the problem?? Codes below..

Cheers,
Andy
<SCRIPT LANGUAGE='JavaS cript1.2'>
function setMenuComment( arg)
{
//remove row
var tbl = document.getEle mentById('menuC ommentTable');
var lastRow = tbl.rows.length ;
if (lastRow > 0) tbl.deleteRow(l astRow - 1);

//add row
var lastRow = tbl.rows.length ;
var iteration = lastRow + 1;
var row = tbl.insertRow(l astRow);
row.setAttribut e('align', 'left');

// left cell
var cellLeft = row.insertCell( 0);
blank = document.create TextNode('blank ');
cellLeft.append Child(blank);

// right cell
var cellRight = row.insertCell( 1);

var pEl = document.create Element('p');
if(arg=='main') { text = document.create TextNode('intro duction area');
cellRight.setAt tribute('width' ,'750');}
else if(arg=='cv'){ text = document.create TextNode('perso nal profile and
information'); cellRight.setAt tribute('width' ,'600');}
else if(arg=='downlo ads'){ text = document.create TextNode('softw are and
documents to download'); cellRight.setAt tribute('width' ,'450');}
else if(arg=='links' ){ text = document.create TextNode('links to other
sites of interest'); cellRight.setAt tribute('width' ,'300');}
pEl.appendChild (text);
cellRight.appen dChild(pEl);
cellRight.setAt tribute("class" , "menuInfo") ;
}
</SCRIPT>

//html
<!-- Menu Info Area -->
<tr><td border="0">
<table border="0" align="center" cellpadding="0"
cellspacing="0" vspace="0" id="menuComment Table">
<tr>
<td class="menuBar" width="100%"
style="border-bottom:1px solid #DCDCDC"><a>&nb sp;</a></td>
</tr>
</table>
</td></tr>
//stylesheet
td.menuInfo
{
border-left:1px solid #DCDCDC;
border-bottom:1px solid #EFEFEF;
height: 20;
text-align: left;
vertical-align: middle;
line-height: 1;
}
Jul 23 '05 #1
3 1475


AndyG wrote:

cellRight.setAt tribute("class" , "menuInfo") ;


Use
cellRight.class Name = "menuInfo";
setAttribute in IE is misbehaving so you are better off scripting
properties and that way the script is working in other browsers too.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #2
On Thu, 30 Sep 2004 13:47:35 +0100, AndyG <An************ @BAAESYSTMES.CO M>
wrote:
I'm trying to mess about with a table using javascript. I'm deleting the
current row then adding a new row and adding a couple of columns. I then
want to add either a style attribute and add a border to the bottom of
one
of the cells or add a class attribute and set it up in the stylesheet.
Problem is, when I try to use the setAttribute it doesn't do anything.
Don't use setAttribute in HTML documents. As far as I know, all standard
attributes have shortcut properties available. So, setting the class
changes from:

element.setAttr ibute('class', '...');

to

element.classNa me = '...';
From:

element.setAttr ibute('width', '8em');

to

element.width = '8em';
That may, or may not, solve your problem.
In fact when I try and set any attribute of cellLeft or cellRight such as
bgcolor=red; it does nothing. It sets the width ok though!
All of those attributes are deprecated. I don't think cellLeft/Right even
exist. If they do, they're proprietary.

Use CSS. No align attributes. No bgcolor. Just up-to-date, structural
mark-up.

[snip]
<SCRIPT LANGUAGE='JavaS cript1.2'>
Dear Lord! Don't EVER use JavaScript1.2 as the language specification
unless you know what you're doing. The language rules changed in that
version and Netscape-like browsers respect those changes.

Stick to the type attribute. It's required anyway, and makes the language
attribute redundant.

<script type="text/javascript">
function setMenuComment( arg)
{
//remove row
var tbl = document.getEle mentById('menuC ommentTable');
var lastRow = tbl.rows.length ;
if (lastRow > 0) tbl.deleteRow(l astRow - 1);


[snip]

If this code is for the Web, read up on feature detection. Not all
browsers in use support DOM methods and properties.

<URL:http://jibbering.com/faq/#FAQ4_26>

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #3
Thanks, that worked

"Michael Winter" <M.******@bluey onder.co.invali d> wrote in message
news:opse45apr2 x13kvk@atlantis ...
On Thu, 30 Sep 2004 13:47:35 +0100, AndyG <An************ @BAAESYSTMES.CO M>
wrote:
I'm trying to mess about with a table using javascript. I'm deleting the
current row then adding a new row and adding a couple of columns. I then
want to add either a style attribute and add a border to the bottom of
one
of the cells or add a class attribute and set it up in the stylesheet.
Problem is, when I try to use the setAttribute it doesn't do anything.


Don't use setAttribute in HTML documents. As far as I know, all standard
attributes have shortcut properties available. So, setting the class
changes from:

element.setAttr ibute('class', '...');

to

element.classNa me = '...';
From:

element.setAttr ibute('width', '8em');

to

element.width = '8em';
That may, or may not, solve your problem.
In fact when I try and set any attribute of cellLeft or cellRight such as bgcolor=red; it does nothing. It sets the width ok though!


All of those attributes are deprecated. I don't think cellLeft/Right even
exist. If they do, they're proprietary.

Use CSS. No align attributes. No bgcolor. Just up-to-date, structural
mark-up.

[snip]
<SCRIPT LANGUAGE='JavaS cript1.2'>


Dear Lord! Don't EVER use JavaScript1.2 as the language specification
unless you know what you're doing. The language rules changed in that
version and Netscape-like browsers respect those changes.

Stick to the type attribute. It's required anyway, and makes the language
attribute redundant.

<script type="text/javascript">
function setMenuComment( arg)
{
//remove row
var tbl = document.getEle mentById('menuC ommentTable');
var lastRow = tbl.rows.length ;
if (lastRow > 0) tbl.deleteRow(l astRow - 1);


[snip]

If this code is for the Web, read up on feature detection. Not all
browsers in use support DOM methods and properties.

<URL:http://jibbering.com/faq/#FAQ4_26>

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.

Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1479
by: void | last post by:
Please take a look at this page: http://home.comcast.net/~delerious1/index5.html It behaves as I expect in Mozilla and Opera, but there are two glaring differences in IE (5.5): 1) The anchors go all the way across the page. 2) When you move the mouse over the lower anchors, the margins on the higher anchors disappear!
6
7936
by: harry | last post by:
Hi, I have a program that runs on multiple client pc's. Occasionally one or more of those pc's use VPN to connect to another corporate network. When using VPN they need to set proxy server in Internet Explorer connection settings (proxy:8080). However, as soon as this setting is enabled, the remoting program running on their pc stops communicating with the server it sends data to. I've disabled proxy setting on the affected pc, rebooted...
4
1631
by: Patrik | last post by:
Hi, I need help on this one. For the past two days, whenever I make a modification to a stored procedure using enterprise manager (Apply), the stored procedure stops working. If I copy it under a new name, it works but as soon as I make a modification, it stops working. I am going crazy on this one. The error : wrong column name. He doesn't recognize the column name on
8
3399
by: nick | last post by:
I have a problem and I've been using a cheezy work around and was wondering if anyone else out there has a better solution. The problem: Let's say I have a web application appA. Locally, I set it up as C:\domains\appA. Locally, my IIS root points to C:\domains. I don't point it to C:\domains\appA since if I have an appB under C:\domains I wouldn't be able to get to it. So to access it via my browser I go to localhost/appA.
3
2897
by: Jan Krouwer | last post by:
I have a problem that shows up only on some systems - the toolbar text in buttons is not visible (vb.net 2003 app, 1.1 framework). As a workaround, I changed the textalign property to "right". This solved the problem, but I don't know what's happening. I notice that there is a small "dot" in the first toolbar button that shows up in either of the textalign property choices. Perhaps this is why the text disappears but I didn't put the dot...
1
3684
by: rory | last post by:
Have the following setting in my app.config: <setting name="Scenes" serializeAs="Xml"> <value> <ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <string>State Img;c:\scenes\Scene1\;5000;1;0;0;0;3</string> <string>Local
5
4098
by: Segfahlt | last post by:
I need a little help here please. I have 2 win forms user controls in 2 different projects that I'm hosting in 2 different virtual directories. The controls have been test and operate okay in both projects. Both controls(dlls) have been signed using SN.exe and I've set up the appropriate .Net assembly permissions using those Strong Names The DLL's have been copied to the /bin directory in both web virtual directories.
5
2935
by: snow | last post by:
Hi All, ToOADate can change a date value to a double value, but if I change the Regional and Lauguage setting in control panel, for example, change English(US) to English(Australia) , the same date time will get different double values from function ToOADate. How to always get the same double value no matter what setting is in control panel? Thanks for the help!
3
1961
by: Dreea | last post by:
Hello i have a .netapplication that runs with no problem when launched from the local machine, but when i try to run the same executable from the network the applications doesn't start. I suppose that the .exe.config file has something to do with it. Here is the content of the configuration file <?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <sectionGroup name="userSettings"...
0
9656
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9498
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10373
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10177
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9969
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8995
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7519
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5538
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4074
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.