Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 4th, 2006, 05:21 AM
Authorized User
 
Join Date: Oct 2006
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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.

 
Old November 4th, 2006, 05:38 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

AFAIK, this can't be done. And I am glad you can't.... ;)

Check out my post in this thread: http://p2p.wrox.com/topic.asp?TOPIC_ID=13884 to see what I mean....

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
 
Old November 6th, 2006, 10:10 AM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

BTW, please don't cross post to multiple forums, once is enough.
Other thread: http://p2p.wrox.com/topic.asp?TOPIC_ID=51855

Regards,
Rich

--
Author,
Beginning CSS: Cascading Style Sheets For Web Design
CSS Instant Results

http://www.catb.org/~esr/faqs/smart-questions.html





Similar Threads
Thread Thread Starter Forum Replies Last Post
Default values when setting up an object data sour mikener ASP.NET 2.0 Professional 0 November 3rd, 2008 09:12 AM
Setting of web config file epkgupta General .NET 0 July 9th, 2008 09:32 AM
setting the value of a file object swarnap Javascript How-To 3 November 6th, 2006 11:13 AM
Setting stylesheet for dynamically created object tgopal Javascript 2 September 6th, 2004 11:47 PM
File security setting wwshi Classic ASP Basics 0 March 30th, 2004 10:20 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.