0

I have a frontend module with this php file under tmpl folder. It fills with joomla's published categories and shows a checkbox for each one, based on current registered user preferences from a table:

<div class="userfavcats<?php echo $moduleclass_sfx ?>">
<div class="row-striped">
    <?php foreach ($list as $item) : ?>
    <div class="row-fluid">
        <div class="span6">
            <strong class="row-title">
             <?php echo $item->name; ?>               
            </strong>
        </div>
        <div class="span3">
            <input type="checkbox" name="data" value="<?php echo $item->id; ?>" <?php if($item->selected) echo(" checked ");?>/>        
        </div>          
    </div>
<?php endforeach; ?>
<input type="submit" value="Save" />
</div>

The idea is to allow the user to check/uncheck categories and send that new selection to the module and save it back to the DB. I haves the following code in my mod_userfavcats module, based on helloworld com_ajax sample. The problem is that don´t know how to obtain each checked value as an array, for example.

(function ($) {
$(document).on('click', 'input[type=submit]', function () {
    var value   = $('input[name=data]').val(),
        request = {
                'option' : 'com_ajax',
                'module' : 'userfavcats',
                'data'   : value,
                'format' : 'raw' 
            };
    $.ajax({
        type   : 'POST',
        data   : request,
        success: function (response) {
            $('.status').html(response);
        }
    });
    return false;
});

})(jQuery)

thank you very much !

1 Answer 1

0

With a JQuery, you can find checkboxes and return checked property. https://stackoverflow.com/questions/426258/checking-a-checkbox-with-jquery

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.