Thursday, September 23, 2010

Remove link on Lookup Field in List

When we add lookup column to any list item add item, the link appears on lookup column. If you check the link, link something like "http://Site/ListName/DispForm.aspx?ID=ID of that field>>&RootFolder=*". 

we find all the Anchor element of the document and check index of href attributes "&RootFolder=*". If you get this attributes simple remove link of lookup.

Add "Content Editor Web Part" webpart on AddItem.aspx page of list. Add the following javascript in webpart:-

<script language="javascript" type="text/javascript">

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;


  1. Thanks you saved me! This still works. I used it on dispform.aspx.