Created
August 8, 2017 22:19
-
-
Save steveafrost/ca4c41e35d34727aed3c02fa6e70366b to your computer and use it in GitHub Desktop.
Add prev, current, and next month to Gravity Form select field
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; | |
var now = new Date(), | |
prev = monthNames[now.getMonth() - 1] + " " + now.getFullYear(), | |
current = monthNames[now.getMonth()] + " " + now.getFullYear(), | |
next = monthNames[now.getMonth() + 1] + " " + now.getFullYear(), | |
optionsField = $('.gfield_select'), | |
options = [prev, current, next]; | |
optionsField.empty(); | |
$.each(options, function (i, option) { | |
optionsField.append($('<option>', { | |
value: i, | |
text: option | |
})); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment