Connecting Tech Pros Worldwide Forums | Help | Site Map

Applying CSS styles to dynamic texbox

Newbie
 
Join Date: Feb 2008
Posts: 18
#1: Mar 3 '08
Hi
I am creating a textbox dynamically on click of a button. I want to apply some styles to that textbox using a CSS file. How can i do that using javascript in a HTML page? The following is the code i am using .

Expand|Select|Wrap|Line Numbers
  1. var cell2 = row.insertCell(1);
  2. var addRowTextNode2 = document.createElement('input');
  3. addRowTextNode2.type = 'text';
  4.  
  5. addRowTextNode2.name = 'CN'+iIteration;
  6. addRowTextNode2.id = 'CN'+iIteration;
  7. cell2.appendChild(addRowTextNode2);
  8.  
Thanks
Daitasri

gits's Avatar
Moderator
 
Join Date: May 2007
Location: Munich, Germany
Posts: 4,136
#2: Mar 3 '08

re: Applying CSS styles to dynamic texbox


there are different ways:

Expand|Select|Wrap|Line Numbers
  1. // first example - one specific style
  2. node_ref.style.color = 'red';
  3.  
  4. // second - a class
  5. node_ref.className = 'your_css_class_name';
  6.  
kind regards
Newbie
 
Join Date: Feb 2008
Posts: 18
#3: Mar 3 '08

re: Applying CSS styles to dynamic texbox


Hi
Thank you for your sparing valuble in helping me. I tried using this ,its fine but i m creating a dropdown also after creating the textbox.Now after i include this statement
node.className='class';
its just creating a textbox and after that its not creating the dropdowns. Its showing error there. Please help me with this.
Thanks
Daitasri
gits's Avatar
Moderator
 
Join Date: May 2007
Location: Munich, Germany
Posts: 4,136
#4: Mar 3 '08

re: Applying CSS styles to dynamic texbox


show your code please ...

kind regards
Reply