Skip to main content
added 130 characters in body
Source Link
tyshock
  • 1.3k
  • 9
  • 15

In SharePoint 2010, the default display forms include an anchortag in the table rows with a name attribute of:

SPBookmark_YourFieldName

If you are using those default display forms, you can take advantage of this and locate your values using jQuery like the following. In this example, my date field is named 'SiteCreateDate':

// my example list field is named SiteCreateDate

// this will fetch the value:
var myDateValue = $('a[name*=SPBookmark_SiteCreateDate]').closest('tr').children().eq(1).text().trim();
    
// do your days left calculation here
myDateValue = myDaysLeftFunction(myDateValue);
    
// this will setappend thea valuenew replacingtablerow below the formerinitial date row with your new value
$('a[name=SPBookmark_SiteCreateDate]').closest('tr').children().eq(1).htmlafter('<tr><td class="ms-formlabel"><h3 class="ms-standardheader">Days Left</h3></td><td class="ms-formbody">' + myDateValue + '</td></tr>');

In SharePoint 2010, the default display forms include an anchortag in the table rows with a name attribute of:

SPBookmark_YourFieldName

If you are using those default display forms, you can take advantage of this and locate your values using jQuery like the following. In this example, my date field is named 'SiteCreateDate':

// my example list field is named SiteCreateDate

// this will fetch the value:
var myDateValue = $('a[name*=SPBookmark_SiteCreateDate]').closest('tr').children().eq(1).text().trim();
    
// do your days left calculation here
myDateValue = myDaysLeftFunction(myDateValue);
    
// this will set the value replacing the former value
$('a[name=SPBookmark_SiteCreateDate]').closest('tr').children().eq(1).html(myDateValue);

In SharePoint 2010, the default display forms include an anchortag in the table rows with a name attribute of:

SPBookmark_YourFieldName

If you are using those default display forms, you can take advantage of this and locate your values using jQuery like the following. In this example, my date field is named 'SiteCreateDate':

// my example list field is named SiteCreateDate

// this will fetch the value:
var myDateValue = $('a[name*=SPBookmark_SiteCreateDate]').closest('tr').children().eq(1).text().trim();
    
// do your days left calculation here
myDateValue = myDaysLeftFunction(myDateValue);
    
// this will append a new tablerow below the initial date row with your new value
$('a[name=SPBookmark_SiteCreateDate]').closest('tr').after('<tr><td class="ms-formlabel"><h3 class="ms-standardheader">Days Left</h3></td><td class="ms-formbody">' + myDateValue + '</td></tr>');
Source Link
tyshock
  • 1.3k
  • 9
  • 15

In SharePoint 2010, the default display forms include an anchortag in the table rows with a name attribute of:

SPBookmark_YourFieldName

If you are using those default display forms, you can take advantage of this and locate your values using jQuery like the following. In this example, my date field is named 'SiteCreateDate':

// my example list field is named SiteCreateDate

// this will fetch the value:
var myDateValue = $('a[name*=SPBookmark_SiteCreateDate]').closest('tr').children().eq(1).text().trim();
    
// do your days left calculation here
myDateValue = myDaysLeftFunction(myDateValue);
    
// this will set the value replacing the former value
$('a[name=SPBookmark_SiteCreateDate]').closest('tr').children().eq(1).html(myDateValue);