Solved

Javascript Browse Button

Posted on 2009-04-06
3
575 Views
Last Modified: 2012-05-06
I want to use a graphical image as a browse button rather than html's inherent file button, so I will have to call a Javascript function at the onclick event that mirrors what the html file button does (launches a file browsing window). Does anybody know the function? If there is a .submit a .open, a .close and a .print, then there must be a sort of .browse function but I can't seem to find that on the net. Everybody talks about the html file button. Basically, I need the function to launch the browse window and then display the path of the file in a text box next to it after the file has been selected and the window is closed, and then have that file get sent. I know it's got to be easy, but i can't find it. Thanks in advance
0
Comment
Question by:BobHavertyComh
  • 2
3 Comments
 
LVL 12

Accepted Solution

by:
Dean OBrien earned 500 total points
ID: 24078025
Hey Bob,

I believe this should work:
<form id="form1">
 <input size="40" id="fbutton" type="file" style="display:none">
 <img src="graphicFileName.jpg" onclick="form1.fbutton.click()">
</form>

Easynow
0
 
LVL 9

Author Closing Comment

by:BobHavertyComh
ID: 31567045
Now that's an interesting little trick. I haven't tried it but I can see exactly what you're doing, and it's probably the easiest thing to do and it will work, so I'll awards the points
0
 
LVL 12

Expert Comment

by:Dean OBrien
ID: 24078235
Just realised that the text box would also be hidden... that being the case an option might be to place the new image over the top of the button instead of hiding it.
Good luck, cheers for the points
Easynow
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now