homepage Welcome to WebmasterWorld Guest from 54.196.63.93
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
Remove value from parameter in URL [Javascript]
remove, value, parameter, URL
lennnert



 
Msg#: 4410417 posted 8:46 pm on Jan 24, 2012 (gmt 0)

Hi

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!

 

rocknbil

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



 
Msg#: 4410417 posted 4:30 pm on Jan 25, 2012 (gmt 0)

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?

lennnert



 
Msg#: 4410417 posted 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!

lennnert



 
Msg#: 4410417 posted 10:27 pm on Jan 28, 2012 (gmt 0)

Nobody can help me ? :(

Skier88

5+ Year Member



 
Msg#: 4410417 posted 10:24 am on Jan 31, 2012 (gmt 0)

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+',')
.replace(','+n+',',',')
.substr(1).replace(/,$/,'');
}

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved