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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T15:35:06+00:00 2026-06-04T15:35:06+00:00

I don’t understand why my code doesn’t work. I create dynamically groups of three

  • 0

I don’t understand why my code doesn’t work.

I create dynamically groups of three buttons: the first button of the group has id 1, the second 101 and the third 201; buttons of the second group will be named respectively 2, 102 and 202, and so on.

If I want to delete all the three buttons by clicking the last one it works. This is what I set in the onclick event :

butt.onclick = function() {
    removeElement(this.id);
    removeElement(this.id-100);
    removeElement(this.id-200);
}

But if I want to delete all the three buttons by clicking the middle one with this onclick event:

butt.onclick = function() {
    removeElement(this.id+100);
    removeElement(this.id);
    removeElement(this.id-100);
}

it eliminates only buttons 1 and 101 but not 201.

It seems like it doesn’t like the “this.id+100” value. What’s the reason?

Thanks in advance.

  • 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-06-04T15:35:08+00:00Added an answer on June 4, 2026 at 3:35 pm

    Your mixing strings with numbers … and using the + with a string concatenates try

    butt.onclick = function() {
        removeElement(parseInt(this.id,10)+100);
        removeElement(this.id);
        removeElement(parseInt(this.id,10)-100);
    }
    

    You use parseInt() to convert strings to numbers in JavaScript

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

Sidebar

Related Questions

Don't know a whole lot about streams. Why does the first version work using
Don't know why this doesn't work. I can't do implicit animation for a newly
Don't be scared of the extensive code. The problem is general. I just provided
Don't know if this has been asked before, so point me to another question
Don't think that I'm mad, I understand how php works! That being said. I
Don't be frightened, its a very basic code. Just wanted to check with you
Don't they both have to convert to machine code at some point to execute
Don't shoot me, but it's the first time I saw a usage of a
Don't be to hard on me, this is my first try with JSF. I
Don't these two mean the same thing, first get the value and then increment?

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.