question about a customised button in a form

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
orangeapple
Forum Commoner
Posts: 70
Joined: Tue Jan 06, 2004 1:24 pm
Location: Geneva / Switzerland

question about a customised button in a form

Post 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 ?
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post 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
User avatar
no_memories
Forum Contributor
Posts: 145
Joined: Sun Feb 01, 2004 7:12 pm
Location: New York City

Post 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">
Last edited by no_memories on Wed Feb 11, 2004 5:41 pm, edited 1 time in total.
Unipus
Forum Contributor
Posts: 409
Joined: Tue Aug 26, 2003 2:06 pm
Location: Los Angeles, CA

Post by Unipus »

Or even:

.reset {
background: url(../media/bouton_reset.jpg);
}


That should work. I've never tried it, actually.
Post Reply