In Sharepoint 2010 I'm trying to do a custom google search based on the currently logged in user's username. For example if a user named john clicked on the link he would be directed to http://www.google.com/search?q=john
In order to get a user's username from the AD and display it in a page, I'm using this property:
<SPSWC:ProfilePropertyValue PropertyName="PreferredName" runat="server" id="ProfilePropertyValue6"/>
So far I have come across this javascript snippet which allows me to concatenate a variable to the end of google's search url:
<script type="text/javascript">
var url = "john";
</script>
<a href="http://www.google.com/search?q=" onclick="location.href=this.href+url;return false;">Link</a>
By assigning john to the url variable I am able to concatenate the username to the end of the url.
However, what I want to do is assign the SPSWC:ProfilePropertyValue... to the variable url so that each individual user's username is concatenated to the end of google's url.
So far I have tried assigning SPSWC:ProfilePropertyValue... to the url variable:
var url = <SPSWC:ProfilePropertyValue PropertyName="PreferredName" runat="server" id="ProfilePropertyValue6"/>;
This didn't work because I can't seem to call the property value inside of the script tags, so it will have no effect.
So what is the proper way of modifying the url with javascript?