setting the value of a file object

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • swarnap
    New Member
    • Sep 2006
    • 15

    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]<html >
    <head>
    <script type="text/javascript">
    function fun()
    {
    document.getEle mentById('j').v alue="hi"
    alert(document. getElementById( 'j').value);
    }
    </script>
    </head>

    <body>
    <input type="file" value="hello" id="j" />
    <input type="button" onclick="alert( document.getEle mentById('j').v alue);"
    <input type="button" onclick="fun(); "
    </body>
    </html>
    [/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.
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Setting the value of input file elements is usually not supported by browsers - see this link for more information.

    Comment

    Working...