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

  • Home
  • SEARCH
  • 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 6207907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:42:54+00:00 2026-05-24T05:42:54+00:00

My current URL is: http://something.com/mobiles.php?brand=samsung Now when a user clicks on a minimum price

  • 0

My current URL is: http://something.com/mobiles.php?brand=samsung

Now when a user clicks on a minimum price filter (say 300), I want my URL to become

http://something.com/mobiles.php?brand=samsung&priceMin=300

In other words, I am looking for a javascript function which will add a specified parameter in the current URL and then re-direct the webpage to the new URL.

Note: If no parameters are set then the function should add ? instead of &

i.e. if the current URL is http://something.com/mobiles.php then page should be re-directed to http://something.com/mobiles.php?priceMin=300
instead of http://something.com/mobiles.php&priceMin=300

  • 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-24T05:42:55+00:00Added an answer on May 24, 2026 at 5:42 am

    try something like this, it should consider also cases when you already have that param in url:

    function addOrUpdateUrlParam(name, value)
    {
      var href = window.location.href;
      var regex = new RegExp("[&\\?]" + name + "=");
      if(regex.test(href))
      {
        regex = new RegExp("([&\\?])" + name + "=\\d+");
        window.location.href = href.replace(regex, "$1" + name + "=" + value);
      }
      else
      {
        if(href.indexOf("?") > -1)
          window.location.href = href + "&" + name + "=" + value;
        else
          window.location.href = href + "?" + name + "=" + value;
      }
    }
    

    then you invoke it like in your case:

    addOrUpdateUrlParam('priceMin', 300);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

my current url is something like: http://something.somedomain.com/about_us/profile.php?tab1=about_us a more complicated on is: http://something.somedomain.com/exchange_hosting/feature/outlook_web_access.php?tab1=exchange_hosting&tab2=feature&tab3=outlook_web_access i
Current url is http://myapp.appspot.com/something/<user-id> or http://127.0.0.1:8080/something/<user-id> How in my python code I can get
I'm trying to utilize ZeroClipboard (http://code.google.com/p/zeroclipboard/wiki/Instructions) to copy the current URL to the user's
Okay, here's my current code for an array. $sites[0]['url'] = http://example0.com; $sites[1]['url'] = http://example1.com;
I have a url (http://www.something.com/subdirectory/image.jpg) and I would like to split the url into
if my current controller, my URL is: http://test.mysite.com/Person/Detail/1 how can i extract into a
With my current function: http://piza.com/something returns pizza.com How do I change it so it
Suppose I have two url for the same file, say http://site.com/fr/page.php and http://site.com/en/page.php .
Let's say my current URL is http://domain.com/category/cars/?page=2 How do I validate on this page
If my current url is www.example.com/thank-you, how do I echo out the page name

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.