Wednesday, May 29, 2013

Get Form Field Values from DispForm.aspx, EditForm.aspx Pages in SharePoint

If you have a requirement to extract field values from Display Form or Edit Form pages in SharePoint lists, Use these jQuery scripts:

Get Form field value in Display Form (DispForm.aspx):

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>

<script language="javascript" type="text/javascript">
 
  $(document).ready(function() {
     var fldValue = $('h3:contains("Last Name")').closest('td').next('td').text();
     alert(fldValue.trim());
   });

</script>

Get Form field value in Edit Form (EditForm.aspx):
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
 
  $(document).ready(function() {
var fldValue = $("input[title*='Last Name']").val();
alert(fldValue.trim());
});

</script>

Use the control tags and attributes accordingly. E.g. For Drop-downs, Instead of "Input" You got to use "Select" tag. 
Use Firebug/IE developer tool to fetch the Tag/Title/ID attributes of required controls!



You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Check out these SharePoint products:

No comments :

Post a Comment

Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...