PDA

View Full Version : changing <input type="file to an image ?? is it possible


chris_angell
11-20-2002, 07:38 PM
hello
I have a form and in this form is an option to select a file from your hard drive by using a

<input type="file" size="20">

but the problem is I want to change the browse option to a graphic, I have tried this the normal way.. but with no luck

<input type="image"

is it possible to replace with a graphic ??

I have also tried to do it another way.. this is

<form action="file:///c|/">
<input type="submit" value="c:\ drive">
</form>

but I am having trouble this way to add the value of the file selected to an input box so it can be selected then open...


what can I do.

brothercake
11-20-2002, 08:42 PM
You can set the font, color and background of a browse button, but that's it. You can't otherwise change its appearance.

This is a deliberate security consideration, so that file input boxes can never masquerade as something else.

glenngv
11-21-2002, 08:37 AM
i've seen the solution posted here before, so im sharing this:

<form name="f">
<input type="file" name="RealAttachment" id="att" style="display:none" onchange="this.form.FakeAttachment.value=this.value">
<input type="text" name="FakeAttachment">
<a href="#" onclick="RealAttachment.click();return false">
<img src="attachment.jpg" width="30" height="20" border="0" valign="bottom">
</a>
</form>

this works in IE only.
don't know if it can be made to work in NS6
I've read this thread (http://codingforums.com/showthread.php?s=&threadid=7495) that can assign HTML elements a click() method, but I can't get it to work.

chris_angell
11-25-2002, 02:06 PM
thanks that is ace, it does the job perfectly.. thank you