Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    May 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy Applying CSS class to a file type input element using JavaScript

    Hi all,

    I am trying to create an input element of type file using the javascript. I am able to create it but the problem i am facing is, i need to apply a CSS class to the control. Can some one let me know how to do the same.

    I am pasting the code that i am using to create a control.

    function AddUploadFile()
    {
    var newrow = document.getElementById("files_tbl").insertRow(document.getElementById("files_tbl").rows.length);
    var td1 = newrow.insertCell(0);
    var hiddenFile = document.createElement("input");

    hiddenFile.id = "File" + document.getElementById("files_tbl").rows.length;
    hiddenFile.name = "File" + document.getElementById("files_tbl").rows.length;
    hiddenFile.type = "file";
    hiddenFile.className = "uploadtool";
    hiddenFile.runat = "server";
    td1.appendChild(hiddenFile);
    }

    Thanks & Regards,
    Arun
    Last edited by ArunKumarS; 05-06-2009 at 10:18 AM.

  • #2
    New to the CF scene
    Join Date
    May 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    use the below logic, it may help you

    var x = document.getElementsByTagName('input');
    for (var i=0;i<x.length;i++)
    {
    x[i].className = 'file hidden';
    }

    Regards, MSS
    Last edited by Maddi; 05-06-2009 at 01:23 PM.

  • #3
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    ||||If you are getting paid to do a job, don't ask for help on it!||||


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •