"Michael Winter" <M.Winter@blueyonder.co.invalid> wrote in message
news:opsjdatha5x13kvk@atlantis...[color=blue]
> On Tue, 21 Dec 2004 16:09:41 GMT, juglesh <juglesh@nospamRadioKDUG.com>
> wrote:
>
> [snip]
>[color=green]
>>
http://www.domain.com?THIS=yes&that=...otherthing=154
>>
>> I need it to look for THIS
>> if THIS is present, and THIS= yes
>> then MyVar = "my string here"
>> if THIS does not = yes
>> then MyVar = "not yes string here"
>> if THIS is not present
>> then MyVar = "not yes string here"[/color]
>
> var url = document.URL,
> i = url.indexOf('THIS='),
> j = url.indexOf('&', i);
> if(-1 == j) {j = url.length;}
> if((-1 == i) || ('yes' != url.substring(i + 5, j))) {
> /* 'THIS' doesn't exist or is not equal to 'yes' */
> }
>
> or for something more generic:
>
> /* Returns the value associated with a key in the query string.
> *
> * If the key doesn't exist or doesn't have a value, undefined
> * is returned.
> */
> function getQueryValue(name) {
> var url = document.URL,
> i = url.indexOf(name += '='),
> j = url.indexOf('&', i);
> if(-1 == j) {j = url.length;}
> if(-1 != i) {return url.substring(i + name.length, j);}
> }
>
> if('yes' != getQueryValue('THIS')) {
> /* 'THIS' doesn't exist or is not equal to 'yes' */
> }
>[/color]
ok, thanks for the reply, i'm using RobB's solution, one reason is i dont
understand yours. where is MyVar?