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 2 of 2
  1. #1
    New to the CF scene
    Join Date
    May 2006
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    setting the value of a file object

    I have a control on me screen of type <FILE>. I want to set some value to that object from the database. I tried the following code using html.


    <html >
    <head>
    <script type="text/javascript">
    function fun()
    {
    document.getElementById('j').value="hi"
    alert(document.getElementById('j').value);
    }
    </script>
    </head>

    <body>
    <input type="file" value="hello" id="j" />
    <input type="button" onclick="alert(document.getElementById('j').value);"
    <input type="button" onclick="fun();"
    </body>
    </html>
    but none of the above showed proper values for alert. it was showing null.

    If I'm entering some values into the file field manalyy then proper alert is coming.
    If I change the file type to text, then it is setting the value in the textfield with the value in the value attribute.

    So my question is how to I set the value into the <FILE> type through the code implicitly.

  • #2
    Senior Coder
    Join Date
    Dec 2004
    Location
    Essex, UK
    Posts
    2,636
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I don't think it's possible as it could be considered a security risk.

    You don't have a semi-colon after document.getElementById('j').value="hi" by the way.


  •  

    Posting Permissions

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