Closed Thread Icon

Preserved Topic: "Browse..."- Can it be an image? Pages that link to <a href="https://ozoneasylum.com/backlink?for=8712" title="Pages that link to Preserved Topic: &amp;quot;Browse...&amp;quot;- Can it be an image?" rel="nofollow" >Preserved Topic: &quot;Browse...&quot;- Can it be an image?\

 
Author Thread
Thumper
Paranoid (IV) Inmate

From: Deeetroit, MI. USA
Insane since: Mar 2002

posted posted 06-11-2003 21:50

I was wondering if anyone knew how I could make the standard "Browse..." button an image. It's not entirely necessary, but I thought I'd ask anywho...

Dracusis
Maniac (V) Inmate

From: Brisbane, Australia
Insane since: Apr 2001

posted posted 06-12-2003 02:00



Huh?

What browser button exactly?

Thumper
Paranoid (IV) Inmate

From: Deeetroit, MI. USA
Insane since: Mar 2002

posted posted 06-12-2003 02:58

Sorry Drac, lemme specify. The "Browse..." button in an HTML form that is used as input for file uploads. I was wondering if instead of the typical browser button, one could use an image instead...

amikael
Bipolar (III) Inmate

From: övik
Insane since: Dec 2002

posted posted 06-12-2003 03:05

Hide the input/file tag by placing it "top:-300", and set it's id to 'myfile'.
Then this code works.

function getFile()
{
myfile.click();
alert(myfile.value);
}

This code can be called from anything, images or buttons, that can be clicked.
Note that the input/file window is modal, so the next line of javasript wont execute until a value has been retrieved from 'myfile'.



(^-^)b

Thumper
Paranoid (IV) Inmate

From: Deeetroit, MI. USA
Insane since: Mar 2002

posted posted 06-12-2003 20:45

amikael,
Thanks for the advice, unfortunately I do not quite understand how I would implement this. I am not at all programming savvy. Any chance you could disclose a scenario?

poi
Paranoid (IV) Inmate

From: France
Insane since: Jun 2002

posted posted 06-13-2003 00:08

amikael: Your idea is interesting. In an attempt to illustrate your point to Thumper, I decided to go for a more stable way to hide the file field.

code:
<html>
<body>

<form>

<input id="myHiddenFileField" type="file" style="display:none">
<img src="img/checkbox_1.gif" width="44" onclick="simulateClickOnHiddenFileField('myHiddenFileField')">

</form>

</body>
<script language="javascript">

function simulateClickOnHiddenFileField( fieldId )
{
fieldHandle = document.getElementById( fieldId)
if( fieldHandle )
{
fieldHandle.click()
if( fieldHandle.value != "" )
alert( "you selected the following file :\n"+ fieldHandle.value )
else
alert( "you selected nothing" )
}
else
alert( "field not found" )
}

</script>
</html>

Unfortunately, the click() seems to have no effect neither in Mozilla 1.3 nor Netscape 4.8. More, NN4.8 can't find the file field if it's hidden via display:none

Gosh!

Mathieu "POÏ" HENRI

[This message has been edited by poi (edited 06-13-2003).]

Thumper
Paranoid (IV) Inmate

From: Deeetroit, MI. USA
Insane since: Mar 2002

posted posted 06-14-2003 00:58

Thank you POI. This will be for an administration tool, so browser version doesn't matter that much.

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 06-14-2003 01:07

The onClick issue should be easily solved by surrounding the image with a null href

<a href="javascript:void(0)" onClick="simulate..."><img src="whatever.. </a>



.:[ Never resist a perfect moment ]:.

poi
Paranoid (IV) Inmate

From: France
Insane since: Jun 2002

posted posted 06-14-2003 16:18

bitdamaged: I wasn't talking about that very onClick event, anyway that's a good thing to remind this NN4 work around to the beginning inmates. Actually, I was mentionning this line:

code:
fieldHandle.click()

I tested different methods to hide the file field ( and even checked to let it visible ) in MZ1.3 and the browser doesn't interpret the line above by throwing an onClick event on the fieldHandle object.

Thumper: Glad, that fits your requirements. I'd never thought about replacing the plain file fields but I'll consider this in my next projects.


Mathieu "POÏ" HENRI

CPrompt
Maniac (V) Inmate

From: there...no..there.....
Insane since: May 2001

posted posted 06-16-2003 04:43

am I just not understanding the question? Why now just use a standard input with the type being image:

<input type="image" .............

Or is this just totatly wrong?

Later,

C:\


~Binary is best~

Nevel
Bipolar (III) Inmate

From: Amsterdam
Insane since: Jun 2002

posted posted 06-16-2003 12:20

Poi,

I haven't tested this, but it doesn't sound weird to me that NS4 refuses to see the hidden field.
display:none really means: get this element out of my document. visibility:hidden might just do the trick, however..



poi
Paranoid (IV) Inmate

From: France
Insane since: Jun 2002

posted posted 06-16-2003 14:07

Nevel: Indeed, NN4.8 behavior might sound correct. I don't have the standards in mind but since Mozilla CAN find an element hidden via display:none , then I consider that NN4.8 is buggy on that point

CPrompt: The image and file type fields are quite differents. The image type behaves like the button or submit field type while the file let the user select a file that will be uploaded with the form.

Mathieu "POÏ" HENRI

CPrompt
Maniac (V) Inmate

From: there...no..there.....
Insane since: May 2001

posted posted 06-16-2003 16:32

poi: yes but he said:

quote:
how I could make the standard "Browse..." button an image



which would leave me to beleive that he just wanted the button that you click to be an image instead of a standard form button. Like I said, I may be reading this wrong but it just seems that is what he was wondering.

Later,

C:\


~Binary is best~

« BackwardsOnwards »

Show Forum Drop Down Menu