Improved: Useful parameter usage extension and small fix of
getDependentDropdownValues in miscAjaxFunctions.js.
Thanks Kyra Pritzel-Hentley for reporting and providing the patch.
@@ -39,12 +39,28 @@ function getDependentDropdownValues(request, paramKey, paramField, targetField,
input = '#' + inputField;
targetTitle = target + '_title'
optionList = '';
- jQuery.ajax({
- url: request,
- data: [{
+
+ var paramData = new Array();
+ // if there are multiple paramKeys (because of multiple dependencies) then create
+ // an array with multiple data information
+ if (paramKey.indexOf(",") > -1) {
+ var paramKeyArr = paramKey.split(",");
+ var paramFieldArr = paramField.split(",");
+
+ // Both arrays should be the same length
+ for (var i=0; i<paramKeyArr.length; i++) {
+ paramData.push({name: paramKeyArr[i], value: jQuery('#' + paramFieldArr[i]).val()});
+ }
+ } else {
+ paramData = [{
name: paramKey,
value: jQuery('#' + paramField).val()
- }], // get requested value from parent drop-down field
+ }] // get requested value from parent drop-down field
+ }
+
+ jQuery.ajax({
+ url: request,
+ data: paramData, // get requested value from parent drop-down field
async: false,
type: 'POST',
success: function(result){
@@ -63,15 +79,15 @@ function getDependentDropdownValues(request, paramKey, paramField, targetField,
if (typeof value == 'string') {
values = value.split(': ');
if (values[1].indexOf(selected) >= 0 && selected.length > 0 && selected == values[1]) {
- optionList += "<option selected='selected' value = " + values[1] + " >" + values[0] + "</option>";
+ optionList += "<option selected='selected' value = '" + values[1] + "' >" + values[0] + "</option>";
} else {
- optionList += "<option value = " + values[1] + " >" + values[0] + "</option>";
+ optionList += "<option value = '" + values[1] + "' >" + values[0] + "</option>";
}
} else {
if (value[keyName] == selected) {
- optionList += "<option selected='selected' value = " + value[keyName] + " >" + value[descName] + "</option>";
+ optionList += "<option selected='selected' value = '" + value[keyName] + "' >" + value[descName] + "</option>";
} else {
- optionList += "<option value = " + value[keyName] + " >" + value[descName] + "</option>";
+ optionList += "<option value = '" + value[keyName] + "' >" + value[descName] + "</option>";
}
}
})
