It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum

Button change thing

Button change thing

Postby Johnathan on Mon Dec 29, 2008 5:08 am

Hi, I'm making a file upload form and I need users to be able to click on the Browse button and it opens up file browser thing and lets them choose a file. When they select it and it and click ok I need the browse button to change from Browse to Upload. How would I do that?
Johnathan
1000+ Club
 
Posts: 1207
Joined: Thu May 31, 2007 3:28 pm
Location: Belfast, Northen Ireland

Re: Button change thing

Postby rangana on Tue Dec 30, 2008 4:42 am

Apparently, you can't actually, change the value of the "file" button.

However, you might find this link useful on a way to style the file button:
http://www.quirksmode.org/dom/inputfile.html
http://www.shauninman.com/archive/2007/ ... nd_the_dom

Hope that helps.
User avatar
rangana
500+ Club
 
Posts: 935
Joined: Wed Feb 27, 2008 5:14 am
Location: Cebu City Philippines

Re: Button change thing

Postby Johnathan on Tue Dec 30, 2008 5:28 pm

Thanks, I think that's the only stuff I found on it to. So is there any way to replace the Browse button image with the Upload image when a file is selected?
Johnathan
1000+ Club
 
Posts: 1207
Joined: Thu May 31, 2007 3:28 pm
Location: Belfast, Northen Ireland

Re: Button change thing

Postby Etheryte on Tue Dec 30, 2008 10:10 pm

Couldn't you make two divs, first one with the browse button, the second one with the upload button? The first one would be visible at first and hidden after a file is selected and then vice verse. Could that work?
Image
User avatar
Etheryte
250+ Club
 
Posts: 255
Joined: Sun Mar 16, 2008 12:21 pm

Re: Button change thing

Postby Johnathan on Tue Dec 30, 2008 10:12 pm

But something would have to detect that the file has been chose so I'm guessing if I an get that far I would be able to change the button image.
Johnathan
1000+ Club
 
Posts: 1207
Joined: Thu May 31, 2007 3:28 pm
Location: Belfast, Northen Ireland

Re: Button change thing

Postby rangana on Wed Dec 31, 2008 9:40 am

Haven't you tried to call a function once the "browse" button had been clicked.

Inside the function you could take a look if the value is empty, otherwise, then there could be some files being uploaded.

Additionally, the better way is to use an "onsubmit" event on the form that contains the "file" button. When someone submits, you could check for the "input type=file" button to see if there is a value, then you could show the "upload" button that you want and hide the "browse" button that you hate.

Hope that makes sense.

P.S. Happy New year to all
User avatar
rangana
500+ Club
 
Posts: 935
Joined: Wed Feb 27, 2008 5:14 am
Location: Cebu City Philippines

Re: Button change thing

Postby Johnathan on Wed Dec 31, 2008 2:06 pm

...No! lol I'm seriously terrible with JavaScript, I don't have any clue what so ever what is going on anywhere.
Johnathan
1000+ Club
 
Posts: 1207
Joined: Thu May 31, 2007 3:28 pm
Location: Belfast, Northen Ireland


Who is online

Users browsing this forum: No registered users and 6 guests