...

View Full Version : setting the value of a file object



swarnaprava
11-04-2006, 08: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 >
<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.

mark87
11-04-2006, 10: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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum