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)&#123;
var pass=true
var first=-1
if (document.images)&#123;
for (i=0;i<which.length;i++)&#123;
var tempobj=which.elements&#1111;i]
 if (tempobj.type=="text")&#123;
  eval(tempobj.value="")
  if (first==-1) &#123;first=i&#125;
 &#125;
 else if (tempobj.type=="checkbox") &#123;
  eval(tempobj.checked=0)
  if (first==-1) &#123;first=i&#125;
 &#125;
 else if (tempobj.col!="") &#123;
  eval(tempobj.value="")
  if (first==-1) &#123;first=i&#125;
 &#125;
&#125;
&#125;
which.elements&#1111;first].focus()
return false
&#125;
</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.