This the code in the var named available_dates
var available_dates = ["08-11-2018","09-11-2018"]
I wonder how can I choose the second date of the var and selected, to my second code
document.getElementById('app_date').value = available_dates
This the code in the var named available_dates
var available_dates = ["08-11-2018","09-11-2018"]
I wonder how can I choose the second date of the var and selected, to my second code
document.getElementById('app_date').value = available_dates
You can simply access a value in your array available_dates by doing this:
document.getElementById('app_date').value = available_dates[i]
Be careful to the fact that indexes start from 0. so available_dates[0] will return the first index. available_dates[1] will return the second and so on.
U must indicate which position of the array u want:
document.getElementById('app_date').value = available_dates[1]
Be happy!!
Simply access array by its key available_dates[1]
function getDate() {
var available_dates = ["08-11-2018","09-11-2018"]
document.getElementById("myText").value = available_dates[1];
}
<input type="text" id="myText" value="">
<button onclick="getDate()">Get Date</button>
Link for javascript array
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array