View Full Version : Using a query string to change css 'ID' name

10-12-2006, 03:41 PM
Without going into too much detail (coz it's a bit complicated), does anyone know how to change the '1' in the CSS ID name '#link1' below, using a query string?

I've played around by trying to make the ID name into a variable (www.mysite.com?myLink=2 etc), but I don't know what I'm doing?

<link href="myFonts.css" rel="stylesheet" type="text/css">

<style type="text/css">
#link1 {
background-color: #D7EBB0;


I would be very grateful if someone can tell me please?


10-13-2006, 08:02 AM

I have a similar problem.

I know you can get the query string from the page's url with window.location.search, but evaluating that string is another matter. I would like to be able to get values from a string using a function.

For example:
A function call such as:


should return 'smith'.

I'm guessing this would involve using regular expressions somehow, but this is definitely not my area of expertise.

It would also be nice to be able to change values in the query string,

for example:


should change the url to:

Thanks for your help

EDIT: Found another post which answers my question: http://www.dynamicdrive.com/forums/showthread.php?t=11883&highlight=query+string