Tuesday, April 14, 2015

Overwrite the values in New/Edit Form using PreSaveMethod in SharePoint


function PreSaveItem()
{

var titleid = document.querySelector("input[title='Sitting DateTime']").id;
var calval=document.getElementById(titleid).value;
var calYear=calval.split('/')[2];
var calMonth=calval.split('/')[0];
var YearID= document.querySelector("input[title='Year']").id;
document.getElementById(YearID).value=calYear;
var mnth='';
switch (calMonth)
{
case '1':
  mnth="January";
  break;
case '2':
 mnth="February";
  break;
case '3':
  mnth="March";
  break;
case '4':
  mnth="April";
  break;
case '5':
  mnth="May";
  break;
case '6':
  mnth="June";
  break;
case '7':
  mnth="July";
  break;

case '8':
  mnth="August";
  break;

case '9':
  mnth="September";
  break;

case '10':
  mnth="October";
  break;
case '11':
  mnth="November";
  break;

case '12':
  mnth="December";
  break;


}
var MonthID= document.querySelector("input[title='Month']").id;

document.getElementById(MonthID).value=mnth;
return true;
}

No comments:

Post a Comment