I've already posted on how to refference SharePoint field with JavaScript (here - with functio getField).
For "Date and Time" type of fields you can use the above function only to refference the Date part. Thanks to Erik / Tanker who commented my post and discovered that these dropdowns get the same ID but just have added "Hours" or "Minutes" to it I'm posting now the 2 more functions to refference Hours and Minutes with these kind of fields.
There are numerous options - you can merge all together in one function, you can make separate functions, etc. I've decided to make two additional functions:
1. You'll need the getField function I've already posted
2. Add the two following functions:
function getDateFieldHours(fieldTitle) {
var dateField = getField('input',fieldTitle)
return document.getElementById(dateField.id+'Hours')
}
function getDateFieldMinutes(fieldTitle) {
var dateField = getField('input',fieldTitle)
return document.getElementById(dateField.id+'Minutes')
}
So if you have for example "Start Time" field which is Date and Time you can refference:
- the Date part with getField('input','Start Time')
- the Hours part with getDateFieldHours('Start Time')
- the Minutes part with getDateFieldMinutes('Start Time')
No comments:
Post a Comment