2009/02/08

Getting Vlaue of UserField In Sharepoint using JavaScript


If you need to get the value of userFiled control using javascript.

<SharePoint:FormField runat="server" id="ff2{$Pos}" ControlMode="New" FieldName="_x0627__x0644__x0631__x0642__x06" __designer:bind="{ddwrt:DataBind('i',concat('ff2',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@_x0627__x0644__x0631__x0642__x06')}"/>



<SharePoint:FieldDescription runat="server" id="ff2description{$Pos}" FieldName="_x0627__x0644__x0631__x0642__x06" ControlMode="New"/>



you can search for this ID in viewsource you can find many controls one of these controls is Span it's ID will be in my case



"ctl00_m_g_271a3a52_3741_466d_80b4_eb05da86cc05_ff2_1_ctl00_ctl00_UserField"



you can use the following code to preview the value of the control



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

function CheckUser()

{

var selectedUser= document.getElementById('ctl00_m_g_271a3a52_3741_466d_80b4_eb05da86cc05_ff2_1_ctl00_ctl00_UserField').innerText; alert(selectedUser); return false;

}

</script>




This control contains the value of this field

It will breview the following value
then you can use this value in filteration or any other Issue





No comments: