/    Sign up×
Community /Pin to ProfileBookmark

Changing all check boxes

Aloha,

I have a form that is dynamically created. It is a list of email addresses with a check box next to each one. The administrator can choose who to include in the email from this list.

The form is created with the checkboxes all having the same name so that when it is passed to the handler there is just a long delimited string.

Now the administrator wants to have a button for SELECT ALL. I know how to do this if I rewrite the dynamic scripts in both the form and form handler. However, I am wondering if there is a way of just changing ALL of them at once. I thought that just setting the textbox to checked would change them all, but it doesn’t seem to work.

Any ideas?

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@DonHauthorSep 26.2005 — It wasn't working because I was trying to do it by tag name not ID. I forgot that the ID can be different from the name so now it works.

?
Copy linkTweet thisAlerts:
@CharlesSep 26.2005 — The "id" and the "name" need to be the same!!!<script type="text/javascript">
function selectAll (f) {
var e, i = 0
while (e = f.elements[i++]) {if (e.type == 'checkbox') e.checked = true}
}

document.write ('<button onclick="selectAll (this.form)">Select All</button>')
×

Success!

Help @DonH 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 6.17,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...