double drop down

federico85 05 Apr, 2013
Hi guys,
i set up a custom search form using CC V4...
now i would like to insert a double drop down (the items to be shown in the second drop down have to depend on what have been selected in the first one)...
i followed lots of tutorials but it seems to me that ajax does not work with CC...
ain't it true?
is there a way to make it working?

Tks!

Federico
GreyHead 05 Apr, 2013
Hi Federico,

You are right that the CC search form has limited functionality. But you can link a ChronoForm to the CC Listing and use that as your search form; the Ajax should work OK then.

Bob
federico85 06 Apr, 2013
that's perfect bob!
now it works but i have two other questions:
this is the code i use to make double drop down working
<?php
$district =& JRequest::getString('sid', '', 'post');
if ( $district ) {
  $db =& JFactory::getDBO();
  $query = "
    SELECT `name`,`city`
      FROM `#__chronoforms_data_anagrafica_enti`
      WHERE `year` = '$district'
      ORDER BY `name`;
  ";
  $db->setQuery($query);
  $data = $db->loadObjectList();
  if ( count($data) ) {
    $m = new stdClass();
    $m->id = 0;
    $m->SchoolName = 'Select School';
    $data = array_merge(array($m), $data);
    $return = JHTML::_('select.genericlist', $data, 'name',
'class="inputbox required select" size="1" ', 'id', 'name','city', 0);
  } else {
    $return = "Sorry, we couldn't find that District";
  }
} else {
  $return = "Sorry, we couldn't find a district id";
}
echo $return;
$mainframe->close();
?>

$mainframe =& JFactory::getApplication(); $mainframe->close();

and i guess that the part of code that shows requested data in the second drop down is this:
 $return = JHTML::_('select.genericlist', $data, 'name',
'class="inputbox required select" size="1" ', 'id', 'name', 0);

I really don't understand how it works cause i don't know anything about ajax...
Could you kindly explain to me how to show data in the drop down list as NAME - CITY and how to make the form consider the cf_created_by correspondent to the NAME - CITY selection?

Thanks in advance...

Federico
federico85 10 Apr, 2013
Ok... i solved replacing the code i didn't understand with an echo of a drop down...
GreyHead 10 Apr, 2013
Hi federico85,

That will work OK.

The code you didn't understand is a Joomla! function to create a drop-down list. The Joomla! docs are here but not terribly helpful :-(

Bob
This topic is locked and no more replies can be posted.