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 3348702
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:34:29+00:00 2026-05-18T01:34:29+00:00

Currently an event is set on checkboxes , and event.target gives me the status

  • 0

Currently an event is set on checkboxes, and event.target gives me the status (checked = true/false) of checkbox which is clicked.

I am maintaining an object which keeps the track on all the selected checkboxes

var selectedMap  = {};

if(event.target == true){
    var key = event.target.id;
    var val = event.target.name;
    selectedMap[key] = val;
}

and I want to remove the element from the map which is unselected

else if(event.target == false){
  selectedMap.remove(event.target.id);
}

when I run this it gives me error in Firebug : selectedMap.remove is not a function

So my question is How can I remove the element when the checkbox is unselected ?

  • 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-18T01:34:29+00:00Added an answer on May 18, 2026 at 1:34 am

    Using delete:

    delete selectedMap[event.target.id];
    

    You’re setting the value incorrectly, though. Here’s the correct way:

    if(event.target == true){
        var key = event.target.id;   // <== No quotes
        var val = event.target.name; // <== Here either
        selectedMap[key] = val;
    }
    

    In fact, you could:

    if(event.target == true){
        selectedMap[event.target.id] = event.target.name;
    }
    

    Getting the event target stuff out of the way, it’s easier to envision this with simple strings:

    var obj = {};
    obj.foo = "value of foo";
    alert(obj.foo);    // alerts "value of foo" without the quotes
    alert(obj["foo"]); // ALSO alerts "value of foo" without the quotes, dotted notation with a literal and bracketed notation with a string are equivalent
    delete obj.foo;    // Deletes the `foo` property from the object entirely
    delete obj["foo"]; // Also deletes the `foo` property from the object entirely
    var x = "foo";
    delete obj[x];     // ALSO deeltes the `foo` property
    

    When using a plain object like this, I always use a prefix on my keys to avoid issues. (For instance, what would happen if your target element’s ID was “toString”? The object already has an [inherited] property called “toString” and things would get Very Weird Very Quickly.)

    So for me, I do this:

    if(event.target == true){
        selectedMap["prefix" + event.target.id] = event.target.name;
    }
    

    …and of course:

    delete selectedMap["prefix" + event.target.id];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently using an event to fire off a set of delegates, and
Is there currently a way to subscribe to an event of a wrapped set,
this.Controls.Add(new CheckBox{ Checked = true; }) When I add this in the page_load .
I get the following error even when my JAVA_HOME is set correctly. C:\workspace-sts-2.8.0.RELEASE\JBClient\target>echo %JAVA_HOME%
I currently have event.stopPropagation() to work on a few selectors, but now I need
I'm trying to play a random sound onTouch event (currently working), but the sound
I'm building an events listing site. Currently each event is entered for a specific
I've got a database of historical records from WW2 and currently each recorded event's
Currently I am using a post-build event command line similar to this one: xcopy
I currently use the onKeyDown event and an if/else statement to create keyboard shortcuts:

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.