Hello, CF6 Masters,
Need a hint for the following - with different posts here I have sucesfully created JavaScript code for photo preview + filesize check.
Code works wery well for one file upload:
where File field name is - spFoto[{var:area_repeater38.key}] and ID - spFoto{var:area_repeater38.key}
How can I write this in Javascript? Tried diffferent ways - 'spFoto$k'; 'spFoto[$k]', 'spFoto[key]' etc.... nothing works.
Thank you in advance-
Elita
Need a hint for the following - with different posts here I have sucesfully created JavaScript code for photo preview + filesize check.
Code works wery well for one file upload:
jQuery(document).ready(function(jQ) {Now I need to implement this for the Repeater, where uploadFile will be something like this - spFoto0; spFoto1; spFoto2..... etc.
var uploadFile;
uploadFile = 'spFoto';
uploadFile = jQ('#'+uploadFile);
uploadFile.after("<div id='imagePreview'></div>");
jQ('#imagePreview').hide();
uploadFile.on('click', function() {
jQ('#imagePreview').hide();
});
uploadFile.on('change', function() {
var files, reader;
files = !!this.files ? this.files : [];
if( ((files[0].size/1024)/1024) > 5){
alert("File greater than 5MB!");
event.target.value = '';
return;
} else if ( /^image/.test(files[0].type) ) {
reader = new FileReader();
reader.readAsDataURL(files[0]);
reader.onloadend = function() {
jQ('#imagePreview').css('background-image', 'url(' + this.result + ')');
jQ('#imagePreview').show();
}
}
});
});
where File field name is - spFoto[{var:area_repeater38.key}] and ID - spFoto{var:area_repeater38.key}
How can I write this in Javascript? Tried diffferent ways - 'spFoto$k'; 'spFoto[$k]', 'spFoto[key]' etc.... nothing works.
Thank you in advance-
Elita