/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Unchecking disabled checkbox – why?

Hi

In my form i display mutiple records which each have a checkbox assigned to them. If when the page loads and a record has a checkbox already ticked (based on a database true/false value) then the checkbox is disabled by default.

However, on my form I have a button which allows users to Check/Uncheck all checkbox elements on the form and when the user selects to uncheck all, the disabled checkboxes lose thier checked value. Now, its not a major problem as when the form is submitted nothing changes in the database but from a visual point of view, is there a way of preventing the disabled checked boxes from being unchecked?

Here is my check/uncheck code:

[CODE]
function checkAll(field) {
for (i = 0; i < field.length; i++)
field[i].checked = true;
}

function unCheckAll(field) {
for (i = 0; i < field.length; i++)
field[i].checked = false;
}

[/CODE]

Thanks

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@toenailsinMar 26.2008 — add a line to check the disabled property of the field. something like:

if (!field[i].disabled)
×

Success!

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