Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

Remove value from parameter in URL [Javascript]

remove, value, parameter, URL



8:46 pm on Jan 24, 2012 (gmt 0)


I want to remove a part of the value from the parameter 'Breed' in an URL.
The value of the parameter Breed can be '49,42,7,33,35,5'.

Now I have checkboxes who represents each number. Now I want that if a checkbox is unchecked, the number of that checkbox (the part of the value) will be removed form the value.

So, if I uncheck the checkbox with name '49' I want that the number '49' and the comma after the number will be removed from the value '49,42,7,33,35,5' of the parameter 'Breed'. So '49,42,7,33,35,5' has to become '42,7,33,35,5'.

Attention, the value of parameter 'Breed' can be several numbers or just one number. So, there has to be a check for a single number or multiple numbers. If there are multiple numbers, the comma after that number also has to be removed.

How can I do this?

Sorry but i'm such a noob in javascript!


4:30 pm on Jan 25, 2012 (gmt 0)

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member

Welcome aboard lennert, first, do you even need Javascript? If a checkbox is not checked, it's not posted in a form. Not seeing the relevance - you say "in a URL" but is it a URL you create or receive in some way?


6:57 pm on Jan 25, 2012 (gmt 0)

Hi rocknbil!

I need Javascript or another language that can solve my problem. It sort of a filter-script for advertisements. With that script they can refine their search for a specific advertisment.
If they check a checkbox in the URL, I create a new URL with a new parameter.

Or.. do you have another solution to get a good-working and functionally filter-system ?

Thank you for your post rocknbil!


10:27 pm on Jan 28, 2012 (gmt 0)

Nobody can help me ? :(


10:24 am on Jan 31, 2012 (gmt 0)

5+ Year Member

I'm not going to try to tell you how to design your website, but here's a solution to your original question.

function trimList(list,n) {
return (','+list+',')

// trimList('48,49,50,51',49) == '48,50,51'

Featured Threads

Hot Threads This Week

Hot Threads This Month