Skip to content

Instantly share code, notes, and snippets.

@salsalabs
Created September 5, 2019 16:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save salsalabs/3e53bb66dd15dddc1c2d709ff0fea458 to your computer and use it in GitHub Desktop.
Save salsalabs/3e53bb66dd15dddc1c2d709ff0fea458 to your computer and use it in GitHub Desktop.
Script to replace the contents of a credit card year dropdown with a current list of years. Particularly helpful on Salsa storefront checkout pages, where the year ranges from 2013 to 2023.
<!-- BEGIN: Replace the credit card year dropdown with a current list of years. -->
<script type="text/javascript">
$(document).ready(function() {
var e = $('select[name="ccExpYear"]');
if (e.length != 0) {
$("option", e).remove();
e.append("<option>Year</option>");
var year = new Date().getFullYear();
for (var i = 0; i < 16; i++) {
var v = year + i;
var y = v % 100;
var t = '<option value="' + y + '">' + v + "</option>";
e.append(t);
}
}
});
</script>
<!-- END: Replace the credit card year dropdown with a current list of years. -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment