I personally consider those default buttons quite ugly and if you want a good looking site, you'll most likely use images, in the place of those horid buttons. And if you work in a team with any graphic designer who is worth his salt, he/she will most likely ask you to replace buttons with images.
There is a neat CSS trick, where one can use one images for both 'active' and 'desabled' states of the button. Indeed you can replicate this trick ad-infinum and have as many states as you like. The way it works CSS attributes are used to slide an imaginary window over the button image and display different states. I removed .PHP file for simplicity sake, but you can put it back once you are familiar with this code. You need two files and here they are:
HTML file:
wht_t547902.html
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<?xml version="1.0" encoding="UTF-8" ?>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link type="text/css" media="screen" rel="stylesheet" href="form.css" />
<script>
// This function dirrectly reacts to your mouse click.
function mySubmit() {
// assign our form to object f
var f = document.forms.myForm;
// hide the 'active' button and show 'passive' button, by mainipulating
// CSS display attribute.
f.btnSubmit_0.style.display = 'none';
f.btnSubmit_1.style.display = 'block';
// disable the 'passive' submit button.
f.btnSubmit_1.disabled = true;
}
// In case you do not yet have MySQL and PHP ready, this function will
// react to form's submit action, which happens automatically following
// the mySubmit() function.
function dataSubmit() {
alert("Faking data submission!");
}
</script>
</head>
<body>
<form action="javascript:dataSubmit()" name="myForm" method="post">
Name: <input name="myName" > <br />
Email: <input name="myEmail"> <br />
<div class="submit">
<!--
CSS trick works like this: both buttons share a single bitmap. Initaially
'active' button is visible and 'passive' button is invisible.
After mouse click, JavaScript and CSS styling literarly shifts bitmap to
the right, and exposes 'passive' button.
Since there is no separate upload for 'passive' button's image file, it all
happens in an instant.
-->
<input
name="btnSubmit_0" class="input-button ON" style="display:block;" type="submit" value=""
onClick="javascript:mySubmit();"
/>
<input
name="btnSubmit_1" class="input-button OFF" style="display:none;" type="submit" value=""
/>
</div>
</form>
</body>
</html>
CSS file:
form.css
Code:
/* CSS formating for the form's submit button. */
div.submit { position: relative; height: 170px; }
div.submit .input-button.ON {
background: url(btn_submit.gif) no-repeat;
width: 182px; height: 57px;
cursor: pointer;
border: none;
background-position: -182px 0;
}
div.submit .input-button.OFF {
background: url(btn_submit.gif) no-repeat;
width: 182px; height: 57px;
background-position: 0 0;
}
Enjoy
