HTML Tutorial


 Forum HomeForum Home   FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
RegisterRegister - Not registered yet? Got something to say? Join HTML Code Tutorial!
filling in the File (textbox) field
Post new topic   Reply to topic    HTML Help Forum Index -> HTML Form
View previous topic :: View next topic  
Author Message
danlagi32



Joined: 25 Apr 2008
Posts: 3

PostPosted: Fri Apr 25, 2008 8:58 am     filling in the File (textbox) field Reply with quote

Anyone who can help -

I'm trying to set the File textbox field without having to click on the browse button using the following code:

<input type="file" name="filename" value="trythis.doc" />

but the value is not put into the file textbox. Does anyone know how to manipulate the textbox field?

Thanks!

Dan Luevano
Straystudio



Joined: 14 Apr 2008
Posts: 264
Location: Nord Italy

PostPosted: Fri Apr 25, 2008 10:57 am     Reply with quote

I want just to be a joker here ...


<div style="float: left/right;">
<input type="file" name="filename" value="" />
<div style="width: 60px; position:relative; top: -19px;">trythis.doc</div>
</div>

evolved in this with JavaScript Language:

<div style="float: left/right;">
<input onClick='document.getElementById("joker").style.display="none"; OtherFunctionIfAny();'
type="file" name="filename" value="" />
<div id="joker" style="width: 60px; position: relative; top: -19px;">trythis.doc</div>
</div>

 
danlagi32



Joined: 25 Apr 2008
Posts: 3

PostPosted: Fri Apr 25, 2008 11:15 am     Reply with quote

HA HA, very funny, but not what I was looking for.

Straystudio wrote:
I want just to be a joker here ...


<div style="float: left/right;">
<input type="file" name="filename" value="" />
<div style="width: 60px; position:relative; top: -19px;">trythis.doc</div>
</div>

 
danlagi32



Joined: 25 Apr 2008
Posts: 3

PostPosted: Fri Apr 25, 2008 11:19 am     Reply with quote

ok, now I'm not sure if you're being serious or not!

What I'm looking for is to be able to pass the html page a filename ("C:\SomeFolder\SomeFile.txt") into the textbox field of the <input type=File> form element, and so that when I click on submit, the filename in the box is uploaded, so that I don't have to click on the browse button to populate the textbox field. Is that what you're trying to accomplish with the code snipet?

Thanks.

Dan Luevano
mjpliv



Joined: 11 May 2004
Posts: 402
Location: Nova Scotia

PostPosted: Fri Apr 25, 2008 11:26 am     Reply with quote

I found what may be a solution to your problem on another site.

http://forums.aspfree.com/asp-free-lounge-32/input-type-file-value-c-test-jpg-name-filename-38676.html

I tested it and it seems to work.
Straystudio



Joined: 14 Apr 2008
Posts: 264
Location: Nord Italy

PostPosted: Fri Apr 25, 2008 11:34 am     Reply with quote

mmhm, I am not sure it is much possible.
We should run around the matter, by handlig Links via JavaScript.

Where the default file should go to get opened? The same window, a new one, an iframe, ...
Or something else should happen when clicking Submit, than simply opening a file.

You would it not to be lost, the capability of the INPUT TYPE="File" to call also different a file beyhond the default one, I guess ...
mjpliv



Joined: 11 May 2004
Posts: 402
Location: Nova Scotia

PostPosted: Fri Apr 25, 2008 11:51 am     Reply with quote

I checked the code and it still allows you to browse for a new file and replace the default value. Its actually a pretty elegant solution to the problem.
Straystudio



Joined: 14 Apr 2008
Posts: 264
Location: Nord Italy

PostPosted: Fri Apr 25, 2008 12:08 pm     Reply with quote

"mjpliv",
I am slow, I was still writing when You posted and I could not to be refferring to that solution.

There, just this to get corrected:

style="font-style:veranda; font-size:12px;"

into

style="font-family:verdana; font-size:12px;"

It does not exist "veranda" as font in HTML; they do exist out-door places in some houses, by the way here in Italy are really called veranda !

Besides, font-style:; can be normal or italic.
Straystudio



Joined: 14 Apr 2008
Posts: 264
Location: Nord Italy

PostPosted: Fri Apr 25, 2008 1:01 pm     Reply with quote

mjpliv wrote:
Its actually a pretty elegant solution to the problem.

Yes, it is; and matchs my thought I had at first, to build more Elements togheter and to take advantage of JavaScript.

But it won't work in my Netscape Navigator 9
nor in Mozilla Firefox;
it does work in Internet Explorer 7 (still wanting opening computer's native open file dialog box, though).

I am going to paste it at here, so to have it ready at we readers' hand.
I cut off fonts, to have the way it work as more quikly visible; completed with some quotes, as well.

Change  display: none;  to  display: block;  or empty, so to make the INPUT TYPE="File" as visible.


<html>
<head></head>
<body>

<form name="test_form" method="post" action="test.jsp">
<input type="file" name="browse" value"value" style="display: none;"/>
<input type="text" name="file" value="c:/test.jpg"/>
<input type="button" onClick='javascript: browse.click(); file.value=browse.value;' value="Select a File..."/>
<br/><br/>
<input type="submit" value="Submit The Form Now!"/>
</form>

</body>
</html>
 
Display posts from previous:   
Post new topic   Reply to topic    HTML Help Forum Index -> HTML Form All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
HTML Help Archive
Powered by phpBB © 2001, 2005 phpBB Group
HTML Help topic RSS feed 

 
DARFUR
HOSTING / DESIGN
MAKE MONEY

Home
  |   Tutorials   |   Forum   |   Quick List   |   Link Directory   |   About
Copyright ©1997-2002 Idocs and ©2002-2007 HTML Code Tutorial