none
How to get field value on DispForm.aspx? RRS feed

  • Question

  • I want to pass several field values from ListA's DispForm.aspx to ListB's NewForm.aspx via querystring. The fields are "Single Line Text". For example, when the DispForm.aspx of ListA is opened in IE, the sourcecode is like:

    		<TR>
    		<TD nowrap="true" valign="top" width="165px" class="ms-formlabel"><H3 class="ms-standardheader"><a name="SPBookmark_Processor"></a>Processor</H3></TD>
    		<TD valign="top" class="ms-formbody" width="450px" ID="SPFieldText">
    		<!-- FieldName="Processor"
    			 FieldInternalName="Processor"
    			 FieldType="SPFieldText"
    		 -->
    			Core 2 Duo&nbsp;
    			
    		</TD>
    	</TR>
    
    

    The field name is "Processor" and its value is "Core 2 Duo".

    My question is how can I get the value with the field name?

     

    Thursday, April 21, 2011 10:30 AM

Answers

All replies

  • Try using inline c# script in the dispfrom.aspx page.

    Refer to the following thread

    http://social.msdn.microsoft.com/forums/en-US/sharepointdevelopment/thread/be7c0af8-b883-4193-a0b3-c12b269069ea


    --Cheers
    • Marked as answer by Leoyi Sun Thursday, May 5, 2011 9:59 AM
    Thursday, April 21, 2011 10:45 AM
  • You can use jQuery to get the field value easily with the following syntax:

     

    $("input[title='Processor']").val(); (this assumes your Processor filed is not a drop drown list)

    You can set the fields the same way on the other page

    $("input[title='TargetFieldName']").val("<value from query string>");

    • Marked as answer by Leoyi Sun Thursday, May 5, 2011 9:59 AM
    Thursday, April 21, 2011 12:29 PM
  • Mark,

    your JQuery code doesn't quite cut it when you are talking about dispforms!

    The correct code would be:

    Var sField1 = $('h3:contains("Processor")').closest('td').next('td').text();


    Regards, Marijn Somers|| http://www.beyond-it.be || Twitter: http://twitter.com/marijnsomers || http://marijnsomers.blogspot.com
    • Proposed as answer by victormartins Monday, May 12, 2014 6:52 PM
    Wednesday, September 14, 2011 3:25 PM
  • Hi,

    I want to put javascript which will hide the field which has not value (Blank) so I have put this script in dispform.aspx but it is working in editform.aspx but not working in display form.

    if ($("select[title='Role']").val() == "") {
    $('td.ms-formlabel:contains("Role")').closest('tr').hide();

    }

    Pls helo me to correct this code.

    Thanks,

    Nimish Dhruv.

    Saturday, November 23, 2013 12:20 PM
  • This method works well, but it can cause conflict with similarly named fields. 

    I had two fields titled Assignee and RecommendedAssignee. Using "h3:contains..." failed to differentiate the two when retrieving 'Assignee'.

    The following code will specifically target a field on a SharePoint 2013 display form based on its internal field name

    Internal field name Assign -
    var myAssigneefieldvalue = $('a[name="SPBookmark_Assign"]').closest('td').next('td').text().trim();

    Internal field name RecAssign -
    var myRecAssigneefieldvalue = $('a[name="SPBookmark_RecAssign"]').closest('td').next('td').text().trim();

    Friday, May 5, 2017 1:27 PM