Changing the text of a submit button when clicked can be useful if you are writing an AJAX application or you know that there will be some sort of delay. Providing the user with some form of feedback is a useful way of letting them know they they have done something.
First, we need a form to work with, so I built a quick one here. Notice that the submit button has an onclick action associated with it, this will be used later to enable us to alter the text of the button.
1 2 3 4 5
<form method="get" action=""> <label for="textinput">Text:</label> <input type="text" value="" name="textinput" id="textinput" /> <input type="submit" id="submitbutton" value="Search" onclick="return changeText('submitbutton');" /> </form>
1 2 3 4 5 6 7