Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6862379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:39:16+00:00 2026-05-27T02:39:16+00:00

From what I can tell from reading everything I can find here, this doesn’t

  • 0

From what I can tell from reading everything I can find here, this doesn’t seem to be possible, but I just thought I’d ask.

What I want to do is prevent a checkbox from doing its default toggle action and run a function instead. This function needs to know the checkboxes CURRENT state- as opposed to the state it will be in after the click event has toggled it- and that toggle needs to be prevented.

So say I have this input for example

<input type="checkbox" onclick="setDefault(this);return false;" />

And the setdefault function is something like this

function setDefault(el) {
    if(jQuery(el).is(':checked'))
        {
        alert('Turning current default off- setting default to Home settings');
        jQuery(el).prop('checked',false);
        return; 
        }
    else
        {
        alert('setting a new default');
        jQuery(el).prop('checked',false);
        return; 
        }
}

When that runs it gets the status the checkbox has been changed to, whreas what I need it to do is prevent the status from changing, find out its current status and then decide what to do.

I have tried every combination of preventDefault() and return false I can think of both in the function and the onclick event and have tried using the onchange event etc etc, but nothing seems to allow me to call a function that fires when the checkbox is clicked that allows the function to get the current value of the checkbox before it is changed by the click event.

Probably I just need to rethink this but if there is anything obvious I have missed I’d be most grateful

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T02:39:17+00:00Added an answer on May 27, 2026 at 2:39 am

    Since the change happened already, the state of the checkbox is the opposite of what it is now. That solves your first problem.

    To reset the state, just set the checkbox’s checked value to what it isn’t now, which is what it was before.

    (my, this sounds like something the Mad Hatter would say!)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

From reading the docs I can tell that allowForceBuild will turn off the force
so from what i can tell, you have to specify artifacts and working directory
I have a (from what I can tell) perfectly working Linux setup (Ubuntu 8.04)
NSDecimalNumber is a subclass of NSNumber, and from what I can tell, it implements
i have invoked blackberry calender from my application can anyone tell me how to
How can I tell from the assembly name, or assembly class (or others like
I can't tell from the Python documentation whether the re.compile(x) function may throw an
From the question you can probably tell that I don't know much about code!
Can anyone tell me how to quickly copy Files from a mapped network drive?
How can I tell if return() was called from within the included file. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.