Get name of day OnChange of Jquery Datepicker
Javascript:
<script type="text/javascript">
$("#pickyDate").datepicker({onSelect: function(dateText){
var days = ['Minggu', 'Senin', 'Selasa', 'Rabu', 'Kamis', 'Jumat', 'Sabtu' ];
var selecteddate = new Date (dateText).getDay ();
var weekday = days[selecteddate];
$('#txt_daypk').val(weekday);
}
});
</script>
Fiddle:
https://jsfiddle.net/zcyjq9we/
JQuery Datepicker doesn't change input value
You are confusing the inline value
attribute with the actual value that the input field contains.
By the attribute value, I mean the following:
<input id="deliveryTime" name="deliveryTime" type="text" value="08/05/2015 10:00">
The value attribute is value="08/05/2015 10:00"
. The value could be whatever date you picked that is entered into the input field.
So even if the attribute is value="08/05/2015 10:00"
, the input's actual value, meaning whatever text is in the input field, is the real value.
When you do enter a new value into your input and then use $('#deliveryTime').val()
you will see that your new value is the actual value of the text inside the input field.
If you are keen on changing the attribute of your input field, which I find kind of ambiguous since val()
already returns that value, then you need to do the following:
$('#deliveryTime').change(function(){
$(this).attr('value', $('#deliveryTime').val());
});
So "On each change of the deliveryTime, set the value
attribute to the input value". Fiddle!
As I said, this is ambiguous. I would recommend just using $('#deliveryTime').val()
to fulfill the same purpose.
Listening to onChange on a jQuery datepicker?
Use jquery on input
alongside with the on change
event
$('#datepicker').datepicker()
.on("input change", function (e) {
console.log("Date changed: ", e.target.value);
});
Fiddle
Related Topics
React Open Modal Window on Click in Another Component
Laravel Pdf File Download from Ajax Request (Laravel 5)
Check If a Key Exists Inside a Json Object
How to Hide Blinking Cursor in Input Text
Convert an Object With Multiple Values Per Key into Array of Objects in Js
How to Convert Date Format from Dd.Mm.Yyyy to Dd/Mm/Yyyy in JavaScript
Php - Return Confirm Within PHP Issue
Callback Is Not a Function (But It Is)
Bootstrap Carousel: How to Stop Auto Sliding on Large Screen
Check If Token Expired Using This Jwt Library
What Does Webkitformboundary Mean
How to Compare Two Arrays Using Lodash (The Order Matters)
How to Toggle Class to a Div Element in Reactjs
Detect Click into Iframe Using JavaScript
Javascript Onclick Increment Number
Copy/Paste from Excel to a Web Page