Skip to content

Instantly share code, notes, and snippets.

@vfontjr
Created January 25, 2023 15:08
Show Gist options
  • Save vfontjr/280426d63e7366252fc335956561f6ea to your computer and use it in GitHub Desktop.
Save vfontjr/280426d63e7366252fc335956561f6ea to your computer and use it in GitHub Desktop.
<script>
jQuery(document).ready(function($) {
"use strict";
/* change field_s32q2 to the id of your date input field
* use your browser's inspection tool to verify the id spelling
*/
$('#field_s32q2').on('change', function() {
/* create a constant reference to a day name values */
const days = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
/* create a working date variable from the value of the input field */
var selected_date = new Date($(this).val());
/* display the day name in your text or hidden field
* change field_qh4icy2 to the id of your text or hidden field
* use your browser's inspection tool to verify the id spelling
*/
$('#field_qh4icy2').val( days[selected_date.getDay()] );
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment