Applying CSS styles to dynamic texbox

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • daitasri
    New Member
    • Feb 2008
    • 18

    Applying CSS styles to dynamic texbox

    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 .

    [CODE=javascript]
    var cell2 = row.insertCell( 1);
    var addRowTextNode2 = document.create Element('input' );
    addRowTextNode2 .type = 'text';

    addRowTextNode2 .name = 'CN'+iIteration ;
    addRowTextNode2 .id = 'CN'+iIteration ;
    cell2.appendChi ld(addRowTextNo de2);
    [/CODE]
    Thanks
    Daitasri
    Last edited by gits; Mar 3 '08, 09:57 AM. Reason: added code tags
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5388

    #2
    there are different ways:

    [CODE=javascript]// first example - one specific style
    node_ref.style. color = 'red';

    // second - a class
    node_ref.classN ame = 'your_css_class _name';
    [/CODE]
    kind regards

    Comment

    • daitasri
      New Member
      • Feb 2008
      • 18

      #3
      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

      Comment

      • gits
        Recognized Expert Moderator Expert
        • May 2007
        • 5388

        #4
        show your code please ...

        kind regards

        Comment

        Working...