2

This is the current state of a module I'm trying to make. From the backend I select some names , and the photos of that names and in the frontend names and photos i selected will get printed at index page. The module's base functionality is working really fine, the only thing is that I want to add 2 more elements: Counter and Selected.

Counter: Is the number of names the user selected.A jquery script that will parse the count of selected names from first field and will show the number in a text box.

Selected: Will be a textarea with every name selected.One More jquery script that will parse every selected name and will show em in a textarea.

I have semi-written the code for the counter field ( I must have done something wrong ) , and I would like someone to help me findout why the script isnt working.

enter image description here

Codes:

Jquery script:

<script>
 jQuery(document).ready(function($){
                  var count = $("#jform_params_foreignmanuf :selected").length;
                  return count;
              });
</script>

manulist.php (dropdownlist/custom field)

<?php

defined('JPATH_PLATFORM') or die;
JFormHelper::loadFieldClass('list');
class JFormFieldManulist extends JFormFieldList
{

        protected $type = 'Manulist';


        protected function getOptions()
        {

         $db= JFactory::getDbo();
         $query = $db->getQuery(true);
        $query->select('*');
        $query->from('#__virtuemart_manufacturers_en_gb');
        $db->setQuery($query);
         $items = $db->loadObjectList();
         $options = array();
         if ($items)
         {
          foreach($items as $item)
          {
            $options[] = JHtml::_('select.option', $item->virtuemart_manufacturer_id , $item->mf_name,$item->slug);
          }
         }
         $options = array_merge(parent::getOptions(), $options);
         JHtml::_('script', JUri::root() . 'modules/mod_manufacturers/js/js.js');
         return $options;

        }


}

countermanu.php(text field of selected records)

<?php

defined('JPATH_PLATFORM') or die;
JFormHelper::loadFieldClass('Text');
class JFormFieldManulist extends JFormFieldText
{

        protected $type = 'Countermanu';


        protected function getOptions()
        {

        $doc = JDocument::getDocument();
       $js = '
             jQuery(document).ready(function($){
                 var count = $("#jform_params_foreignmanuf :selected").length;
                 return count;
             });
      ';
       $doc->addScriptDeclaration($js);
        JHtml::_('script', JUri::root() . 'modules/mod_manufacturers/js/js.js');

        }


}

Edit: What i actually need is someone help me to find out why the jquery script isnt running

closed as unclear what you're asking by Valentin Despa Dec 3 '14 at 19:26

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Please specify: What is the non working part? What your code fails to do? – FFrewin Dec 3 '14 at 12:48
  • The counter field is just blank as shown in the picture, so it means my methodology of adding jquery in the backend fails somewhere and i dont know what i do wrong as i never tried it before today. – IseNgaRt Dec 3 '14 at 12:51
  • Check the console log in your browser for any errors – Lodder Dec 3 '14 at 14:37
  • How i actually do that? I read this developer.mozilla.org/en-US/docs/Web/API/Console.log but i cant understand what i have to do. My script call syntax/function is ok ? – IseNgaRt Dec 3 '14 at 14:54
  • Simply press F12, go to the Console tab, then refresh the page. If there are any errors, they will appear in red – Lodder Dec 3 '14 at 15:46