Formulating a form with input elements that are utilizing a jquery datepicker is the current task at hand. Take a look at a snippet of the HTML code for these inputs:
<td style="width:15%"><input type="text" name="datepicker" id="Tb3fromRow10"/></td>
<td style="width:15%"><input type="text" name="datepicker" id="Tb3toRow10"/></td>
An issue has arisen where the date format required is mm/dd/yyyy, while the database only accepts formats in yyyy-mm-dd. As a workaround, the plan is to display dates as mm/dd/yyyy on the form, but use an eventlistener onSubmit to convert all dates to yyyy-mm-dd before being recorded in the database. The approach involves creating an array using getElementsByName (since all elements have been named "datepicker"), changing their formats, and then reassigning their IDs. Progress has been made on the first two steps, with some difficulty encountered when attempting to reassign IDs:
var myArray = document.getElementsByName('datepicker[]');
for(var i = 0; i < myArray.length; i++) {
var sep = myArray.split('/');
var newDate = sep[2]+'-'+sep[0]+'-'+sep[1];
}
**document.getElementsByName('datepicker[]').value = newDate;**
It's evident that the last line is incorrect. Assistance is needed in correctly reassigning all date elements to their corresponding IDs.
Appreciate any guidance!