Hi Bob and thank you🙂
this is that script in mootools.
http://jsfiddle.net/ynternet/pfJYh/8/In chronoforms and joomla...
I added hidden input element with "Field Name" :
web_printscreens[]
This value I read by DB record loader from database.
Then, I added new custom HTML/PHP element with code :
<?php
echo "<label>Edit photos</label>";
if ( isset($form->data['web_printscreens']) && $form->data['web_printscreens'] ) {
$files_array = explode( ",",($form->data['web_printscreens']));
foreach ( $files_array as $photo ) {
echo "<div style='padding:5px; display:inline-block;'>";
echo "<img src='".JURI::root()."img_uploads/".$photo."' style='border:2px solid red; max-width:100px; max-height:100px' /><br />";
echo "<input type='checkbox' name='".$photo."' checked="yes" />";
echo "</div>";
}
}
?>
And in Actions I added to the "onLoad" new Load JS action with this code :
window.addEvent('domready', function() {
var checks = document.getElements('input[type="checkbox"]');
var hidden = document.getElements('input[type="hidden"][name="web_printscreens[]"]')[0];
checks.addEvent('change',function(e){
var checkbox = e.target;
var img = checkbox.getPrevious('img');
var checked = checkbox.get('checked');
if(checked){
img.setStyle('border','2px solid gray');
//alert(img_name);
// hidden.set('value',img_name);
}
else{
img.setStyle('border',null);
//alert(img_name);
// hidden.set('value',img_name);
}
setInputHidden();
});
});
function setInputHidden(){
var inputs_checked = document.getElements('input[type="checkbox"]:checked');
var arr_names = inputs_checked.get('name');
hidden.set('value',arr_names.join(','));
alert(hidden.value);
}
But it does not remove images.