471,854 Members | 1,911 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,854 software developers and data experts.

Checking if a GET Variable is set - HOW?

Hi guys.

Great site. This site has helped me many times before. But now I have a question to which I am yet to find an answer.

In a nutshell, I need to know how to check if a URL GET variable has been set, and if it has, to set the style of a DIV to display: block;

for instance: www.scott.com/competition.aspx?mode=entry

so.. the GET variable is mode and the value is entry

I would like to know how to check for that variable using javascript, then to have it change the style of my DIV with ID = "entryform" to be visible.

I know this may be a simple one.. but I just can't find anything about checking for GET variables in javascript.

I cannot use ASP, .NET or PHP to do the check.. as I'm working in an HTML template for a CMS.

Any help is greatly appreciated,

thanks in advance,

Mar 26 '08 #1
1 1677
16,027 Expert Mod 8TB
Use the location.search property. Split the string using .split("=") to get the variable/value pair.
Mar 26 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by Guy Robinson | last post: by
9 posts views Thread by Bart Nessux | last post: by
3 posts views Thread by Vinodh Kumar P | last post: by
42 posts views Thread by =?Utf-8?B?UGxheWE=?= | last post: by
125 posts views Thread by jacob navia | last post: by
11 posts views Thread by Bryan Crouse | last post: by
reply views Thread by NeoPa | last post: by
reply views Thread by aboka | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.