Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Javascript Browse Button

Posted on 2009-04-06
3
576 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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…

765 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