PDA

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



jim28100
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;
}
</style>

</head>

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

Jim

Agrajag
10-13-2006, 08:02 AM
Hi

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:
url?firstname=john&lastname=smith
A function call such as:

getQueryStringValue('lastname');

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:

changeQueryStringValue('lastname','brown');

should change the url to:
url?firstname=john&lastname=brown

Thanks for your help

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