473,395 Members | 2,151 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Using image for reset button

What's the best practice for using an image for a reset button?
Unfortunately, we cannot use <input type="image" src="..."in this case.

Any helpful tutorial from the web will be appreciated.

I ran a google search, but a lot of "use my script" type junk websites
are showing up.

Best regards,
Animesh
Jun 21 '07 #1
16 3630
ed
You can simply add an image, and give it an onclick event to clear the
form data

document.FormName.reset();

On Jun 21, 3:34 pm, Animesh K <animesh1...@gmail.comwrote:
What's the best practice for using an image for a reset button?
Unfortunately, we cannot use <input type="image" src="..."in this case.

Any helpful tutorial from the web will be appreciated.

I ran a google search, but a lot of "use my script" type junk websites
are showing up.

Best regards,
Animesh

Jun 21 '07 #2
ed wrote:
You can simply add an image, and give it an onclick event to clear the
form data

document.FormName.reset();

Let me be more specific. I have a "contact us" link which floats an
invisible form by making it visible. I want to put an "abort" button on
the form so that should "reset" the form as well as "make the form
invisible"

I did manage to achieve the effect (see contact us link at the bottom of
the following page:

http://www.stutimandal.com/gif_misc/...ma_stotram.php

)

But I am not sure if this is the best method to implement the task at
hand. It works, obviously.

By the way, the page is under construction, so there may be some errors,
here and there. If you find something nasty, please let me know.

Best regards,
Animesh

>
<snip>
>
Jun 21 '07 #3
RvT
On 21 jun, 14:34, Animesh K <animesh1...@gmail.comwrote:
What's the best practice for using an image for a reset button?
Unfortunately, we cannot use <input type="image" src="..."in this case.

Any helpful tutorial from the web will be appreciated.

I ran a google search, but a lot of "use my script" type junk websites
are showing up.

Best regards,
Animesh
<form name="theform">
<input type="text" size="10" id="afield" name="afield" value="defaut
value" />
<a onclick="document.theform.reset();return false;"
href="#"><img src="test.png" border="0" alt="" width="283"
height="40" /></a>
</form>

Jun 22 '07 #4
RvT
<form name="theform">
<input type="text" size="10" id="afield" name="afield" value="defaut
value" />
<a onclick="document.getElementById('theform').style. visibility =
'hidden';"
href="javascript:document.theform.reset();return false;"><img
src="frank-herrmann/images/photos/frontpage.jpg" border="0" alt=""
width="283" height="212" /></a>

With making the form invisible.

Jun 22 '07 #5
RvT said the following on 6/21/2007 10:06 PM:
<form name="theform">
<input type="text" size="10" id="afield" name="afield" value="defaut
value" />
<a onclick="document.getElementById('theform').style. visibility =
'hidden';"
href="javascript:document.theform.reset();return false;"><img
src="frank-herrmann/images/photos/frontpage.jpg" border="0" alt=""
width="283" height="212" /></a>

With making the form invisible.
Geez, what is it with people posting garbage code that shouldn't even be
considered for a trash can?

Try reading the group FAQ and a thread from just yesterday where it was
explained the best way to make a button/image/link for JS only and
javascript: pseudo-URLs.

Try quoting also.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jun 22 '07 #6
RvT wrote on 22 jun 2007 in comp.lang.javascript:
On 21 jun, 14:34, Animesh K <animesh1...@gmail.comwrote:
>What's the best practice for using an image for a reset button?
Unfortunately, we cannot use <input type="image" src="..."in this
case.

Any helpful tutorial from the web will be appreciated.

I ran a google search, but a lot of "use my script" type junk
websites are showing up.

Best regards,
Animesh

<form name="theform">
<input type="text" size="10" id="afield" name="afield" value="defaut
value" />
<a onclick="document.theform.reset();return false;"
href="#"><img src="test.png" border="0" alt="" width="283"
height="40" /></a>
</form>
<script type='text/javascript'>
function resetMe(f){
f.reset();
f.style.display = "none";
// or: f.style.visibility = "hidden";
};
</script>

<form name='theform'>
<input type='text' name='afield' value='default'>
<br>
<img src='reset.jpg'
onclick='resetMe(document.forms["theform"];)'>
</form>
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jun 22 '07 #7
Evertjan. wrote on 22 jun 2007 in comp.lang.javascript:
RvT wrote on 22 jun 2007 in comp.lang.javascript:
>On 21 jun, 14:34, Animesh K <animesh1...@gmail.comwrote:
>>What's the best practice for using an image for a reset button?
Unfortunately, we cannot use <input type="image" src="..."in this
case.

Any helpful tutorial from the web will be appreciated.

I ran a google search, but a lot of "use my script" type junk
websites are showing up.

Best regards,
Animesh

<form name="theform">
<input type="text" size="10" id="afield" name="afield" value="defaut
value" />
<a onclick="document.theform.reset();return false;"
href="#"><img src="test.png" border="0" alt="" width="283"
height="40" /></a>
</form>

<script type='text/javascript'>
function resetMe(f){
f.reset();
f.style.display = "none";
// or: f.style.visibility = "hidden";
};
</script>

<form name='theform'>
<input type='text' name='afield' value='default'>
<br>
<img src='reset.jpg'
onclick='resetMe(document.forms["theform"];)'>
onclick='resetMe(document.forms["theform"]);'>

</form>



--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jun 22 '07 #8
Evertjan. wrote:
Evertjan. wrote on 22 jun 2007 in comp.lang.javascript:
>RvT wrote on 22 jun 2007 in comp.lang.javascript:
>>>
Thank you Evertjan! I think I have implemented something similar. I will
update my code in case it is different from your's. Thanks again,

Animesh
>>


Jun 22 '07 #9
Animesh K wrote on 22 jun 2007 in comp.lang.javascript:
Evertjan. wrote:
>Evertjan. wrote on 22 jun 2007 in comp.lang.javascript:
>>RvT wrote on 22 jun 2007 in comp.lang.javascript:


Thank you Evertjan! I think I have implemented something similar. I
will update my code in case it is different from your's. Thanks again,
"in case it is different... " ????????

Rest assured it IS different!

By not quoting the crux of the matter, you make it dificult to respond.

You wrote:
<a onclick="document.theform.reset();return false;"
href="#"><img src="test.png" border="0" alt="" width="283"
height="40" /></a>
I wrote:
<img src='reset.jpg'
onclick='resetMe(document.forms["theform"];)'>
So I did away with the impractical

<a onclick='...' href='#">....

which only confuses the issue.

and /which is not usefull at all.

Furthermore I made a function that can be used in more forms,
if needed.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jun 22 '07 #10
Evertjan. wrote:
Animesh K wrote on 22 jun 2007 in comp.lang.javascript:
>Evertjan. wrote:
>>Evertjan. wrote on 22 jun 2007 in comp.lang.javascript:

RvT wrote on 22 jun 2007 in comp.lang.javascript:
Thank you Evertjan! I think I have implemented something similar. I
will update my code in case it is different from your's. Thanks again,

"in case it is different... " ????????

Rest assured it IS different!

By not quoting the crux of the matter, you make it dificult to respond.

You wrote:
> <a onclick="document.theform.reset();return false;"
href="#"><img src="test.png" border="0" alt="" width="283"
height="40" /></a>

I wrote:
> <img src='reset.jpg'
onclick='resetMe(document.forms["theform"];)'>

So I did away with the impractical

<a onclick='...' href='#">....

which only confuses the issue.

and /which is not usefull at all.

Furthermore I made a function that can be used in more forms,
if needed.

You are confusing things with the code that RvT posted here. I have used
something different than RvT.

Check my code out here:

<p><input type="image" src="../images/send_main.png" alt="send"
value="Send Email">
<a href="javascript:fbformdown();"><img class="noline" alt="cancel"
src="../images/cancel_main.png"></a>
</p>

function fbformdown(){
document.likho.reset();
document.getElementById("feedback").style.display= "none";
}
when I said I will compare your code to mine, I meant comparing this
above code to what you have suggested.

Regards,
Animesh
Jun 24 '07 #11
Evertjan. wrote:
Animesh K wrote on 22 jun 2007 in comp.lang.javascript:
>Evertjan. wrote:
>>Evertjan. wrote on 22 jun 2007 in comp.lang.javascript:

RvT wrote on 22 jun 2007 in comp.lang.javascript:
Thank you Evertjan! I think I have implemented something similar. I
will update my code in case it is different from your's. Thanks again,

"in case it is different... " ????????

Rest assured it IS different!

By not quoting the crux of the matter, you make it dificult to respond.

You wrote:
> <a onclick="document.theform.reset();return false;"
href="#"><img src="test.png" border="0" alt="" width="283"
height="40" /></a>

I wrote:
> <img src='reset.jpg'
onclick='resetMe(document.forms["theform"];)'>

So I did away with the impractical

<a onclick='...' href='#">....

which only confuses the issue.

and /which is not usefull at all.

Furthermore I made a function that can be used in more forms,
if needed.

Ok I just compared my script with your's. Your's is better. You do get
rid of the <a href="javascript"etc fluff that I had. And you are right
that your function can be used again and again. Thank you, I will update
my script based on your technique.

Best,
A
Jun 24 '07 #12
Animesh K wrote on 24 jun 2007 in comp.lang.javascript:
>I wrote:
>> <img src='reset.jpg'
onclick='resetMe(document.forms["theform"];)'>
Ok I just compared my script with your's. Your's is better. You do get
rid of the <a href="javascript"etc fluff that I had. And you are right
that your function can be used again and again. Thank you, I will update
my script based on your technique.
If you wish you can add a hand cursor to help the user:

<img
style='cursor;pointer;'
src='reset.jpg'
onclick='resetMe(document.forms["theform"];)'>


--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jun 24 '07 #13
On Jun 24, 3:32 pm, "Evertjan." <exjxw.hannivo...@interxnl.netwrote:
If you wish you can add a hand cursor to help the user:

<img
style='cursor;pointer;'
style='cursor:hand'
src='reset.jpg'
onclick='resetMe(document.forms["theform"];)'>


Jun 24 '07 #14
scripts.contact wrote on 25 jun 2007 in comp.lang.javascript:
On Jun 24, 3:32 pm, "Evertjan." <exjxw.hannivo...@interxnl.netwrote:
>If you wish you can add a hand cursor to help the user:

<img
style='cursor;pointer;'

style='cursor:hand'
Only if you advice to use them both, broadening the cross browser
functionallity with older forms of IE, < IE5.5 I believe.

style='cursor:hand;cursor;pointer;'

However, as the absense of that will do a "graceful degradation" to those
few users.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jun 25 '07 #15
On Jun 25, 1:45 am, "Evertjan." <exjxw.hannivo...@interxnl.netwrote:
scripts.contact wrote on 25 jun 2007 in comp.lang.javascript:
On Jun 24, 3:32 pm, "Evertjan." <exjxw.hannivo...@interxnl.netwrote:
If you wish you can add a hand cursor to help the user:
<img
style='cursor;pointer;'
style='cursor:hand'

Only if you advice to use them both, broadening the cross browser
functionallity with older forms of IE, < IE5.5 I believe.

No. i was correcting the ; and then used the wrong value.
style='cursor:hand;cursor;pointer;'
style="cursor:pointer"

Jun 26 '07 #16
scripts.contact wrote on 26 jun 2007 in comp.lang.javascript:
On Jun 25, 1:45 am, "Evertjan." <exjxw.hannivo...@interxnl.netwrote:
>scripts.contact wrote on 25 jun 2007 in comp.lang.javascript:
On Jun 24, 3:32 pm, "Evertjan." <exjxw.hannivo...@interxnl.netwrote:
>If you wish you can add a hand cursor to help the user:
><img
style='cursor;pointer;'
style='cursor:hand'

Only if you advice to use them both, broadening the cross browser
functionallity with older forms of IE, < IE5.5 I believe.


No. i was correcting the ; and then used the wrong value.
>style='cursor:hand;cursor;pointer;'

style="cursor:pointer"
I see your point ; where : should be. ;-(

My advice:

style = 'cursor:pointer;'

1 Always use the end ; in a style. It looks better and
it is easier to copy/cut paste, drag or copy drag
individual parts of style declarations.

2 I use single quotes as my personal preference in
style='' onclick='' etc.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jun 26 '07 #17

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Matt | last post by:
i need to implement a clear button to clear all the fields in the form, but i am thinking i can just use reset button. <input type="reset" name="reset" value="CLEAR"> The first thought is...
14
by: frizzle | last post by:
Hi there, I have a form on a contact page, and to make the layout cross-browser/-platform i want to use an image as a button instead of using an image as background on a button.... Problem:...
4
by: Tomasz Bak | last post by:
Hello, I have a simple problem: mark a list of defects on an image. I think the best way to do it is to select a single deffect, then take two coordinates of coursor form an image on a web...
3
by: Mark Szlazak | last post by:
The following page simulates a pool cue and cue ball: http://members.aol.com/myscript/cue.html Mouse cursor position around the cue ball determines where a roll-over of 179 pool cue images is...
3
by: Andreas Wöckl | last post by:
HI Group! I have to programmatically create a user input form with various Checkbox and RadioButton lists - Beside every List I have to place an image button that is able to reset the...
16
by: Giovanni D'Ascola | last post by:
Hi. I noticed that <input type="reset"actually don't enable checkbutton which are checked by default after they have been disabled by javascript. It's a bug?
1
by: sourcie | last post by:
I am changing an existing quiz found on "JavaScriptKit.com Multiple Choice Quiz" I have an image. Instead of using the radio buttons with the normal true/false question, I want to place two...
3
omerbutt
by: omerbutt | last post by:
hi i am trying to make a hover class that would replace the background-image of the button .it is working in Mozilla but not working in IE any suggesstions ,here is the code <style...
10
by: sowmyati | last post by:
HI All, I am new to javascript. I have snippet wherein i am giving a brief note on what i am trying to do. In the below have a variable by name stuff. trying to reset the page. Part of the code...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.