http://www.sharepointkings.com/2008/10/remove-link-on-lookup-field.html
if the site is unavailable here is the code needed:
<script language="javascript" type="text/javascript">
_spBodyOnLoadFunctionNames.push("RemoveLookupLinks");
function RemoveLookupLinks()
{
var oP = document.getElementsByTagName('a');//the collection of <a> tags
var flag = false
for(var i=0;i<oP.length;i++)
{
if(oP[i].attributes["href"].value.indexOf("RootFolder=*")!= -1)
{
var linkvalue = oP[i].innerHTML;//value of the lookup field
oP[i].parentNode.innerHTML = linkvalue;//replacing value of the lookup to whole the Anchor tag
flag = true;
break;
}
}
if(flag)
RemoveLookupLinks();
}
</script>
It does mean either hacking the default master or creating your own, which isnt too hard with SharePoint Designer.
Problem for me was, if you had multiple choices on the lookup fields only the first choice was saved.
so I put in a small fix
Replace:
var linkvalue = oP[i].innerHTML;//value of the lookup field
With:
var linkvalue = oP[i].parentNode.innerHTML;
var re = new RegExp("<[aA][^>]+>","gi");
linkvalue = linkvalue.replace(re,"");
var re2 = new RegExp("</[aA][^>]*>","gi");
linkvalue = linkvalue.replace(re2,"");
Now, my regex isnt great, but it works and that is the main thing.
Read the post if you want to see more detail, but I just added a small change to the script which allows multiple links to be replaced.
No comments:
Post a Comment