This topic is locked

Changing the maximum number of uploaded files based on another field value

5/30/2014 12:30:17 PM
PHPRunner Tips and Tricks
Sergey Kornilov admin

In PHPRunner you have an option to specify the maximum number of files to be uploaded. In some cases you want to control this number dynamically depending on other field values right on Add/Edit pages.
For instance, on our cars related classified ads website we want to allow Audi owners to upload up to three pictures while other car owners can only upload one image per ad.


Here is how this can be done. This can needs to be added to Add/Edit page Javascript OnLoad event. In this example Make is dropdown box field name, Pictures is the name of field that stores uploaded images.

var ctrlMake = Runner.getControl(pageid, 'Make');

ctrlMake.on('change', function(e){

var num;

if (this.getValue() == 'Audi'){

num=3;

}else{

num=1;

}

var f=Runner.getControl(pageid,"Pictures");

f.uploadForm.fileupload("option", {

maxNumberOfFiles: num,

constMaxNumberOfFiles: num

});

f.uploadForm.fileupload('refreshMaxFilesState');

});