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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:58:45+00:00 2026-05-25T01:58:45+00:00

I have a bit of Javascript I’m playing with, which is called by a

  • 0

I have a bit of Javascript I’m playing with, which is called by a number of checkboxes and will ideally perform an action (adding and removing &attributeValue=attribID to the URL cumulatively) upon the checkbox being checked/unchecked.

Here’s the Javascript:

var filterBaseURL = <?="\"".$url."\""?>; /*This is just copying a php variable that contains the base URL defined earlier - all of this works fine*/
var filterFullURL = filterBaseURL;
function filterToggle(attribID)
{
  var elementII = document.getElementById(attribID);
  if(elementII.checked){
     filterFullURL = filterFullURL+"&attributeValue="+attribID;
  }
  else {
     filterFullURL.replace("&attributeValue="+attribID, "");
     alert(filterFullURL);
  }
}

So what I’m doing here is attempting to on check of a checkbox add that checkbox’s attributeValue to the URL, and on uncheck of a checkbox, remove that checkbox’s attributeValue from the URL. I am using the filterFullURL = filterFullURL+”…” because there are multiple checkboxes and I want all their attributeValues to cumulatively be added to the URL.

All of this is working fine – the only thing that isn’t working fine is the else statement action –

filterFullURL.replace("&attributeValue="+attribID, "");

Here are some example checkboxes:

<input type="checkbox" onclick="filterToggle('price_range_0_20')" name="Price_Range" value="Below_$20" id="price_range_0_20" /> Below $20
<input type="checkbox" onclick="filterToggle('price_range_20_40')" name="Price_Range" value="$20_-_$40" id="price_range_20_40" /> $20 - $40
<input type="checkbox" onclick="filterToggle('price_range_40_70')" name="Price_Range" value="$40_-_$70" id="price_range_40_70" /> $40 - $70

So to recap – I can add the attributeValues of all the checkboxes together, but I can’t delete any of them. Any help here? Thanks!

  • 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-25T01:58:46+00:00Added an answer on May 25, 2026 at 1:58 am

    Do you not need to save the output of filterFullURL.replace like filterFullURL = filterFullURL.replace(“&attributeValue=”+attribID, “”)?

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

Sidebar

Related Questions

Let's say i have some bit of JavaScript which will modify the DOM, perhaps
I have a bit of javascript that runs on a 3rd party's website which
I have this bit of javascript written with jQuery 1.2.5. It's contained inside the
I have a bit of Javascript code that creates a save friendly version of
I have a bit of javascript that I am using to calculate the y-scale
I have this bit of JavaScript... 15 $('.ajax_edit_address').each(function() { 16 $(this).ajaxForm({ 17 target: $(this).parents('table.address').find('tr.address_header').children(':first'),
I have a bit of JavaScript code that is specified in a configuration file
I'm pulling my hair out over this. I have this bit of javascript that
I have a little bit of Javascript that almost works correctly. Here's the code:
I have a bit of javascript that dynamically multiplies what users are typing in

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.