tags:

views:

92

answers:

1

I'm a newb when it comes to javascript. Perhaps somebody could help me with this. I assume it is not very complicated. This is what I would like:

<SCRIPT type=text/javascript>
    var StandardURL = "http://site/Lists/test/AllItems.aspx";
</script>

<SCRIPT type=text/javascript>
    var FilterURL = "http://site/Lists/test//AllItems.aspx?FilterField1=Judge&amp;FilterValue1=";
</script>

var DynamicURL = FilterURL + DynamicUserInf (no space between it should be like one url link), dynamicuserinf contains different value depending on the user that is logged in no need to worry what is in it. It already contains a value befor this runs

var CurrentURL = current URL where this script is loading

<script language="JavaScript" type="text/javascript">
    if (CurrentURL == StandardURL) { location.href= (DynamicURL);}
</script>

ElSE do nothing (i assume this is not neccarry with only one if statement)

Hopefully not much of a mess.

+2  A: 

For getting current URL :

var CurrentURL = document.URL;

For joining/concatenating the variables (assuming that DynamicUserInf is a variable), you've already got it correct :)

var DynamicURL = FilterURL + DynamicUserInf;
Mr Roys
Thats funny i got the other one accidently correct. Going to test it. Thx for speedy reply
Hi Ierac, your code is correct. However you've a typo error where you declared the var DynamicUserInf as DynmaicUserInf. Try using alert(expression); to check if your code goes into the condition correctly or whether your variables store the correct values, that'll help a lot :)
Mr Roys
Thx for the tip will do so in the future. It is working now.