New Question type. Just a Month-Year type with a month drop down and a 4 digit year text box.

This commit is contained in:
Kaleb Murphy 2009-03-22 18:18:38 +00:00
parent 2151730767
commit cafd31f87a
4 changed files with 48 additions and 2 deletions

View file

@ -23,6 +23,9 @@ if (typeof Survey === "undefined") {
'Dual Slider - Range': 1,
'Multi Slider - Allocate': 1
};
var DATE_SHORT = {
'Year Month': 1
};
var DATE_TYPES = {
'Date': 1,
'Date Range': 1
@ -62,6 +65,16 @@ if (typeof Survey === "undefined") {
alert("Please allocate the remaining " + amountLeft + ".");
}
}
else if (toValidate[i].type === 'Year Month') {
answered = 1;//set to true, then let a single failure set it back to false.
for (var z1 in toValidate[i].answers) {
var m = document.getElementById(z1+'-month').value;
var y = document.getElementById(z1+'-year').value;
if(m == ''){ answered = 0; }
if(y.length != 4) { answered = 0; }
if(answered == 1){ document.getElementById(z1).value = m + "-" + y; }
}
}
else {
for (var z1 in toValidate[i].answers) {
if (YAHOO.lang.hasOwnProperty(toValidate[i].answers, z1)) {
@ -395,7 +408,17 @@ if (typeof Survey === "undefined") {
toValidate[q.id].type = q.questionType;
toValidate[q.id].answers = [];
}
if (DATE_SHORT[q.questionType]) {
for (var k = 0; k < q.answers.length; k++) {
var ans = q.answers[k];
if (toValidate[q.id]) {
toValidate[q.id].type = q.questionType;
toValidate[q.id].answers[ans.id] = 1;
}
}
continue;
}
if (DATE_TYPES[q.questionType]) {
for (var k = 0; k < q.answers.length; k++) {