| View previous topic :: View next topic |
| Author |
Message |
danlagi32
Joined: 25 Apr 2008 Posts: 3
|
Posted: Fri Apr 25, 2008 8:58 am filling in the File (textbox) field |
|
|
|
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
|
Posted: Fri Apr 25, 2008 10:57 am |
|
|
|
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
|
Posted: Fri Apr 25, 2008 11:15 am |
|
|
|
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
|
Posted: Fri Apr 25, 2008 11:19 am |
|
|
|
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
|
|
Straystudio
Joined: 14 Apr 2008 Posts: 264 Location: Nord Italy
|
Posted: Fri Apr 25, 2008 11:34 am |
|
|
|
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
|
Posted: Fri Apr 25, 2008 11:51 am |
|
|
|
| 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
|
Posted: Fri Apr 25, 2008 12:08 pm |
|
|
|
"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
|
Posted: Fri Apr 25, 2008 1:01 pm |
|
|
|
| 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>
|
|
|