/    Sign up×
Community /Pin to ProfileBookmark

Why it works in IE and not in Mozilla:reset fields?

I have code to reset fields:

[code=php]<form id=”remove” action=”<?php echo $PHP_SELF; ?>” method=”post” >
[/code]

and buttons like:

[code=php]
<input type=”image” name=”request” src=”images/send.jpg”
onmouseover=”this.src=’images/send_over.jpg'”
onmouseout=”this.src=’images/send.jpg'”>

<img src=”images/clear.jpg” onclick=”remove.reset();” alt=”reset”
onmouseover=”this.src=’images/clear_over.jpg'”
onmouseout=”this.src=’images/clear.jpg'”
>
<noscript>
<input type=”reset”/>
</noscript>
[/code]

Why in Mozilla does not work the same code?

to post a comment
JavaScript

9 Comments(s)

Copy linkTweet thisAlerts:
@Typhoon101May 14.2007 — What is not working? the reset or the button change?
Copy linkTweet thisAlerts:
@gil_davisMay 14.2007 — <img src="images/clear.jpg" onclick="remove.reset();" [/quote]Because this is a shortcut that FF won't be able to resolve. Change it to:&lt;img src="images/clear.jpg" onclick="[color=red]document.[/color]remove.reset();"
Copy linkTweet thisAlerts:
@toplisekauthorMay 14.2007 — What is not working? the reset or the button change?[/QUOTE]


I would like that reset button will work.

Code does not work even I change to

<img src="images/clear.jpg" onclick="document.remove.reset();"
Copy linkTweet thisAlerts:
@Typhoon101May 14.2007 — [COLOR=black]Try [/COLOR][COLOR=red]onclick="document.getElementById('remove').reset();"[/COLOR]

[COLOR=black][/COLOR]

[COLOR=black]thanks works for me[/COLOR]
Copy linkTweet thisAlerts:
@toplisekauthorMay 14.2007 — [COLOR=black]Try [/COLOR][COLOR=red]onclick="document.getElementById('remove').reset();"[/QUOTE]



this works now.Can I remove:

<noscript>

<input type="reset"/>

</noscript>
Copy linkTweet thisAlerts:
@Typhoon101May 14.2007 — you can do if you want, but that would be useful for those with JavaScript disabled.

For those few people, your image button will still appear, but it will not work. If you want it to be a truely compliant form, you should consider using Javascript to create the whole button, not just the onclick function, then leave the noscript tag in.

For example


&lt;script type="text/javascript"&gt;
btn = "";
btn += "&lt;input type="image" name="request" src="images/send.jpg" onmouseover="this.src='images/send_over.jpg'" onmouseout="this.src='images/send.jpg'"&gt;";
btn += "&lt;img src="images/clear.jpg" onclick="remove.reset();" alt="reset" onmouseover="this.src='images/clear_over.jpg'" onmouseout="this.src='images/clear.jpg'"&gt;";
document.writeln(btn);
&lt;/script&gt;
&lt;noscript&gt;
&lt;input type="submit" value="submit" /&gt;
&lt;input type="reset" value="reset" /&gt;
&lt;/noscript&gt;


This way, JavaScript will create both buttons, but if the user has JavaScript disabled, the standard buttons will appear instead.
Copy linkTweet thisAlerts:
@toplisekauthorMay 14.2007 — so, correct code for reset button is the following (in IE and FF):
[code=php]

<script type="text/javascript">
btn = "";
btn += "<input type="image" name="request" src="images/send.jpg" onmouseover="this.src='images/send_over.jpg'" onmouseout="this.src='images/send.jpg'">";
btn += "<img src="images/clear.jpg" onclick="document.getElementById('remove').reset();" alt="reset" onmouseover="this.src='images/clear_over.jpg'" onmouseout="this.src='images/clear.jpg'">";
document.writeln(btn);
</script>
<noscript>
<input type="submit" value="submit" />
<input type="reset" value="reset" />
</noscript>

[/code]
Copy linkTweet thisAlerts:
@Typhoon101May 14.2007 — This would work in all the major browsers and would produce standard buttons instead of your images, if the user has JavaScript disabled.
Copy linkTweet thisAlerts:
@toplisekauthorMay 15.2007 — Hi,

great, thank you
×

Success!

Help @toplisek spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...