/    Sign up×
Community /Pin to ProfileBookmark

someone know any JavaScript that can clear all check Form (I’m no taking about the check all/uncheck all)

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@mjdamatoAug 27.2007 — I'm assuming English is not your first language. That's not a put down as I don't have any 2nd language. But, your question is not clear.

Are you wanting to clear all text fields? Reset select lists? Reset radio options? Please be specific.
Copy linkTweet thisAlerts:
@liccyauthorAug 28.2007 — well you right is clear that English is no my first language lol. but anyway my problem is the this..

i need a js that will uncheck all the checkboxes before the page is loan w/o any type of buttom that will be uncheck and check it once is click... is that clear now ????
Copy linkTweet thisAlerts:
@mjdamatoAug 29.2007 — Do you mean you want to uncheck all the checkboxes on "load" of the page? Doesn't make sense to me since you should control what fields are checked an which ones are not when the page loads. But, yes it can be done.

Assuming all the checkboxes are inside form tags here is an example:

Simply include this script in the head of the page:
function uncheckBoxes() {
//Iterate through each form
for (f=0; f<document.forms.length; f++) {
//Iterate through every element on the form
for (e=0; e<document.forms[f].elements.length; e++) {
//Determine if element is a checkbox & uncheck it
if (document.forms[f].elements[e].type=='checkbox') {
document.forms[f].elements[e].checked = false;
}
}
}
}


Then include an onload even in the body tag like this:
<body onload="uncheckBoxes();">

Here is a complete working example. Just remove/add the onload event to see the difference
<html>
<head>

<script type="text/javascript">

function uncheckBoxes() {
//Iterate through each form
for (f=0; f<document.forms.length; f++) {
//Iterate through every element on the form
for (e=0; e<document.forms[f].elements.length; e++) {
//Determine if element is a checkbox & uncheck it
if (document.forms[f].elements[e].type=='checkbox') {
document.forms[f].elements[e].checked = false;
}
}
}
}

</script>
</head>

<body onload="uncheckBoxes();">
<form name="form1">
<input type="checkbox" name="check1" checked> Checbox 1<br>
<input type="checkbox" name="check2" checked> Checbox 2<br>
<input type="checkbox" name="check3" checked> Checbox 3<br>
<input type="checkbox" name="check4" checked> Checbox 4<br>
</form>
</body>

</html>
×

Success!

Help @liccy 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.22,
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,
)...