View Full Version : setting the value of a file object

11-04-2006, 09:03 AM
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 >
<script type="text/javascript">
function fun()

<input type="file" value="hello" id="j" />
<input type="button" onclick="alert(document.getElementById('j').value);"
<input type="button" onclick="fun();"
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.

11-04-2006, 11:32 AM
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.