digitalDave
Member
Hello I am trying to dynamically set the number of repeat groups when a form loads.
But I want query the database to find out how many repeats are needed.
I am using this code which works great, I feel I need to dynamically change the value of howManyRepeats.
I am using this code to get the information from database which retrieves the data I want, but I can't seem to marry the two together.
Any suggestions are most welcome?
But I want query the database to find out how many repeats are needed.
I am using this code which works great, I feel I need to dynamically change the value of howManyRepeats.
JavaScript:
requirejs(['fab/fabrik'], function() {
Fabrik.addEvent('fabrik.form.group.duplicate.min', function(form) {
var name = Fabrik.getBlock('form_17').formElements.get('tbl_inspections___dbj_vehicle');
var howManyRepeats = 12;
var group = 90;
form.options.minRepeat[group] = form.options.maxRepeat[group] = howManyRepeats;
});
I am using this code to get the information from database which retrieves the data I want, but I can't seem to marry the two together.
JavaScript:
function getPreviousFaultCount(){
var url = "index.php?option=com_fabrik&format=raw&task=plugin.userAjax&method=countPreviousFaults";
var vehicleId = 8;
new Request(
{
type: 'get',
data: {vehicleId: vehicleId},
async: true,
url:url,
onSuccess: function(response){
console.log(response);
}
}).send();}
}
Any suggestions are most welcome?