Forum Moderators: open

Message Too Old, No Replies

On Click Form Button Image?

         

sunzfan

11:05 pm on Jan 10, 2008 (gmt 0)

10+ Year Member



I have a site where people upload larger images. I'd love it if the "submit" button could change to "loading" after it's been clicked...is this difficult? How might I do that.

gergoe

12:15 am on Jan 11, 2008 (gmt 0)

10+ Year Member



Using the form's onsubmit event handler (onsubmit="<javascript code>"), you can alter the whole document loaded into the browser, you can easily change anything on the page. I'd suggest to give a (html) id to the element where your submit button is placed, and using document.getElementById(), change the container's innerHTML property to the text of your choice.
If you assigned the 'submitContainer' id to the container (td, div, span, whatever is in there) then the following will replace the submit button with the "Please wait..." text:

document.getElementById('submitContainer').innerHTML = 'Please wait...';

This is a simple approach, and a basic example, you may need to extend it with some other things (to make it bulletproof), probably searching on the web for "getElementById" will reveal several good resources in this respect.