Created
January 25, 2023 15:08
-
-
Save vfontjr/280426d63e7366252fc335956561f6ea to your computer and use it in GitHub Desktop.
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
<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