473,405 Members | 2,294 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Dynamicly Created Text Box won't take class attribute

dlite922
1,584 Expert 1GB
i have a table in which i create the rows dynamically with JS.

Everythings works except my sizes are off. they are controlled via CSS class "field1" to "field8"

Here's the code where i set the class, just like any other attribute, id, name, onBlur...

Expand|Select|Wrap|Line Numbers
  1.  
  2. var vDesc = document.createElement('input');
  3.   vDesc.type = 'text';
  4.   vDesc.name = 'violationDescription[]';
  5.   vDesc.id = 'vDesc' + numRows;
  6.   vDesc.tabindex = tabIndex++;     //don't worry about ++
  7.   vDesc.value = "";
  8.   vDesc.class = "field6";                //<------- does not work
  9.   var cell = row.insertCell(1); 
  10.   cell.appendChild(vDesc); 
  11.  
  12.  
weather i change it to field 2 or 8, the text box appears as a standard size.

It is NOT a css problem, because on refresh the textboxes that are there by default display the correct size.

i could do this, but haven't tried
vDesc.style.size = "";

However that defeats the point of putting all formatting in a CSS file.

Anybody know why Firefox 2.0 disregards the class?

(can't test in IE6/7 yet because its got other issues)
Jan 20 '08 #1
2 1460
Logician
210 100+
Expand|Select|Wrap|Line Numbers
  1.  
  2. vDesc.class = "field6";                //<------- does not work
  3.  
vDesc.className = "field6";
Jan 20 '08 #2
dlite922
1,584 Expert 1GB
vDesc.className = "field6";
that worked. i got it from the manual as well, just didn't test it until now.

Just in case someone else comes accross this, i attempted to modify the style and you'll run into a problem with attributes that have dashes in them such as

document.something.style.text-align = "right"

They've enabled these properties in hungarian case, to work you must change text-align to textAlign.

document.something.style.textAlign = "right";

(for the sake of google keyword search & linking:
background-color = backgroundColor
border-color = borderColor
border-width = borderWidth
etc....)
Jan 21 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: FAN | last post by:
I want to define some function in python script dynamicly and call them later, but I get some problem. I have tried the following: ################################## # code...
2
by: Jelle van Baardewijk | last post by:
Can anyone tell me how to to create a control instance dynamicly. Example: When I have a string value with the value 'TextBox'. I want to create a TextBox instance. I know that i can do the...
5
by: Henke | last post by:
Hi! I add some web user controls dynamicly with: myPanel.Controls.Add(Page.LoadControl("MyDynamiclyAddedPage.ascx")); the style of the controls on the user control is set from a css-class, by...
2
by: DaWoE | last post by:
Hi all, I'm fairly new to ASP.NET. What i want to do is creat a online registration form. On the first step is getting the users details and the number of people he wants to register. Based on...
4
by: mcwooq | last post by:
Hi, I just installed the VS.Studio 2005 Team Edition for Developper and encountered severe problems with debugging ASP.NET 2.0 projects. Even newly empty created ASP 2.0 projects can't debug...
5
by: Samuel R. Neff | last post by:
Is there a way to add the NonSerialized attribute to the "Event" fields that the VB.NET compiler creates when you declare an event? I have a class that we use with binary serialization and we...
2
by: Wayne Sepega | last post by:
I have the following Code: foreach (MyClass d in myClassCollection) { curRadioBtn = new RadioButton(); curRadioBtn.Text = d.ToString(); curRadioBtn.GroupName = "Contact"; curRadioBtn.ID =...
4
by: Siah | last post by:
Hi, I wanted to dynamically update pieces of my page in the following fashion. Look at the following html code: <span id='person_23_name'> Mike </span> <span id='person_28_name'> Siah </span>...
5
by: Amoril | last post by:
I've read quite a few different message on various boards and for some reason I'm still having trouble wrapping my head around this viewstate maintenance and trying to get these dynamically created...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
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,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
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,...
0
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...

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.