HTML |
---|
<form class="aui" id="datesForm">
<div class="field-group">
<label for="dd-startDate">Start Date
<span class="aui-icon icon-required">(required)</span></label>
<input class="text medium-field" type="text"
id="dd-startDate" name="dd-startDate">
<div class="description">Please select your Start Date</div>
</div>
<div class="field-group">
<label for="dd-endDate">End Date
<span class="aui-icon icon-required">(required)</span></label>
<input class="text medium-field" type="text"
id="dd-endDate" name="dd-endDate">
<div class="description">Please select your End Date</div>
</div>
<div class="buttons-container">
<div class="buttons">
<input class="button submit" disabled="disabled" type="button" value="Create" id="dd-save-button">
</div>
</div>
</form>
<script>
AJS.$(document).ready(function() {
AJS.$('#dd-startDate').datePicker({'overrideBrowserDefault': true});
AJS.$('#dd-endDate').datePicker({'overrideBrowserDefault': true});
AJS.$('#dd-save-button').click(function(){
AJS.$('.reportedDate').remove();
var datesBetween = getDates(convertToDate(AJS.$('#dd-startDate').val()), convertToDate(AJS.$('#dd-endDate').val()));
for (i=0;i<datesBetween.length;i++){
var cd = datesBetween[i];
AJS.$.ajax({
url: 'https://wiki.vertuna.com/ajax/confiforms/rest/save.action?pageId=11862909&f=myform&mydate=' + cd.getTime(),
type: "GET",
success: function (data) {
showMessage(cd);
}
});
}
});
});
Date.prototype.addDays = function(days) {
var dat = new Date(this.valueOf())
dat.setDate(dat.getDate() + days);
return dat;
}
function getDates(startDate, stopDate) {
var dateArray = new Array();
var currentDate = startDate;
currentDate = new Date(currentDate)
while (currentDate <= stopDate) {
dateArray.push( new Date (currentDate) )
currentDate = currentDate.addDays(1);
}
return dateArray;
}
function convertToDate(dateAsString) {
return new Date(dateAsString); // yy-mm-dd (which is ISO 8601)
}
function showMessage(dateToReport) {
AJS.$('#datesForm').append('<div class="reportedDate aui-message aui-message-info closeable shadowed success"><p>Created record for: ' + dateToReport + '</p></div>');
}
</script> |
ConfiForms Form Definition | ||
---|---|---|
| ||
Created dates
ConfiForms TableView | ||
---|---|---|
| ||
Storage format for the solution (make sure you change the "pageId" parameter from 11862909 to your pageId (of the page with the form))
...