Created
September 5, 2019 16:58
-
-
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.
This file contains 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
<!-- 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