We have some javascript that populates a dropdown for possible dates for a new hire to start. The drop down displays properly when submitting a form but the submission that is routed to the approver shows the selected date followed by the rest of the possible dates.
Here is the script that we are using:
$(document).ready(function () {
$(".thisfieldreadonly input").prop("readonly", true);
getMondays();
});
function getMondays(){
var badMondays = [ '7/21/2014', '9/1/2014', '12/29/2014' ];
var mondays = new Array();
var maxWeeks = 12;
var d = new Date();
while(d.getDay() != 1){
d.setDate(d.getDate() + 1);
}
while(maxWeeks >= 0){
var m = (d.getMonth() + 1) + '/' + d.getDate() + '/' + d.getFullYear();
if(badMondays.indexOf(m) == -1){
mondays.push(m);
maxWeeks--;
}
d.setDate(d.getDate() + 7);
}
//FIND ELEMENT & SET VALUES
//var dd = document.getElementById("XXXX");
for(i=0;i<mondays.length;i++){
$("#Field224").append(new Option(mondays[i], mondays[i]));
}
}
Thanks, Jen
mod edit: You can use the code snippet option on the toolbar to make your code look nice. :)