Page 1 of 1
question about a customised button in a form
Posted: Wed Feb 11, 2004 4:31 am
by orangeapple
Hi !
i would like to add a customised "reset button" in a form. Can anyone send me the proper code ?
this :
<input type="image" src="../media/bouton_reset.jpg" name="reset">
doesn't work
who can help ?
Posted: Wed Feb 11, 2004 4:47 am
by JayBird
You need to use javascript
Paste this in your head tag
Code: Select all
<script language = "Javascript">
function ResetForm(which){
var pass=true
var first=-1
if (document.images){
for (i=0;i<which.length;i++){
var tempobj=which.elementsїi]
if (tempobj.type=="text"){
eval(tempobj.value="")
if (first==-1) {first=i}
}
else if (tempobj.type=="checkbox") {
eval(tempobj.checked=0)
if (first==-1) {first=i}
}
else if (tempobj.col!="") {
eval(tempobj.value="")
if (first==-1) {first=i}
}
}
}
which.elementsїfirst].focus()
return false
}
</script>
Then produce a form like this
Code: Select all
<form onSubmit="return ResetForm(this)" method="post" action="#" name="">
<!-- place all your other fields here -->
<input type="image" border="0" name="imgReset" src="/images/reset.gif" width="62" height="20">
</form>
Mark
Posted: Wed Feb 11, 2004 12:16 pm
by no_memories
or maybe try using css.
style --->
#formreset {
color: #f00;
background: #ccc;
border: 1px solid #00f;
}
html --->
<input type="reset" id="formreset" value="Reset Form">
Posted: Wed Feb 11, 2004 4:29 pm
by Unipus
Or even:
.reset {
background: url(../media/bouton_reset.jpg);
}
That should work. I've never tried it, actually.