I am a at a loss as to achieve this trick :
When u put in a form this :
<input type="file" name="file">
It gives u a field with a little grey button (awful isn't it :) )
Now, what I want to do is this :
u got an image in the webpage, when u click on it, it offers u the
same window as when u click on the button "file" browse : that is, the
image becomes the "browse button".
I thought of putting a href on my image which would call a function
which would emulate the onClick event on the button (which would be in
a hidden frame) but have not managed so far...
Any ideas please ?
Ray
"acey" <kana...@yahoo.fr> wrote in message
news:976aea44.01102...@posting.google.com...
acey
1. On your form, create a normal textfield and name it eg.
<input type="text" name="txtFileName">
this is to hold the name and path of the file
2. Next to your new text field, put the image you want. The image
should have the following onClick event
onClick="BrowseForFile()"
3. Add a HIDDEN Browse Field to your form eg.
<input type="file" name="BrowseDialog" style="display: none">
4. Add the following SCRIPT in the HEAD section of your page
(inbetween the <head> and </head> tags), like this
<head>
<script language="JavaScript">
function BrowseForFile() {
var browseObj = document.getElementById("BrowseDialog");
browseObj.click();
var txtLocation = document.getElementById("txtFileName");
txtLocation.value = browseObj.value;
}
</script>
</head>
5. Here is the completed page
<html>
<head>
<script language="JavaScript">
function BrowseForFile() {
var browseObj = document.getElementById("BrowseDialog");
browseObj.click();
var txtLocation = document.getElementById("txtFileName");
txtLocation.value = browseObj.value;
}
</script>
</head>
<body>
<form>
<input type="text" name="txtFileName">
<img src="Images/Button.png" onClick="BrowseForFile()">
<input type="file" name="BrowseDialog" style="display: none">
</form>
</body>
</html>
NOTE: I have tested this in IE 5.5 only. If you need it to run in
other browsers, I can't help you. As I said I am a total newbie.
Good luck
Greg
"Ranson" <ran...@rlaj.com> wrote in message news:<A70B7.3959$OB1.1...@eagle.america.net>...
thnx a lot I did not know the event "BrowseForFile" : that solves it all
thank uvery much !