Hi you all,
first off all i have to thank you for the wonderful job you're making. Chronoforms is really amazing.
Well, i'm having a few problems coding some stuff that i need. I have a Website that provides learning courses which are inserted in a database. The desired behaviour is - i click on one item in the first drop down menu ( containing all my course's category's ), the second drop down is filled with information asked to the database depending on what item you clicked first, the same process for the 3rd drop down. It is important to state that all the 3 levels are not in the same database table, as you can see in the next presented code.
Note: I have not implemented the 3rd drop down behaviour yet as it is identical to the 2nd.
My code :
Actually, is my first time dealing with php.
Best Regards,
Diogo Ribeiro
first off all i have to thank you for the wonderful job you're making. Chronoforms is really amazing.
Well, i'm having a few problems coding some stuff that i need. I have a Website that provides learning courses which are inserted in a database. The desired behaviour is - i click on one item in the first drop down menu ( containing all my course's category's ), the second drop down is filled with information asked to the database depending on what item you clicked first, the same process for the 3rd drop down. It is important to state that all the 3 levels are not in the same database table, as you can see in the next presented code.
Note: I have not implemented the 3rd drop down behaviour yet as it is identical to the 2nd.
My code :
<?php
$options = array();
$options[] = "<option value=''>--?--</option>";
$options1 = array();
$options1[] = "<option value=''>--?--</option>";
$options2 = array();
$options2[] = "<option value=''>--?--</option>";
$db =& JFactory::getDBO();
$query = "
SELECT `id`, `tipo`
FROM `formacao`;
";
$db->setQuery($query);
$data = $db->loadObjectList();
foreach ( $data as $d ) {
$options[] = "<option value='{$d->id}'>{$d->tipo}</option>";
}
if($d->tipo=="Financiada")
{
$query = "
SELECT `id`, `area_formacao`
FROM `ffinanciada`;
";
$db->setQuery($query);
$data1 = $db->loadObjectList();
foreach ( $data1 as $d1 ) {
$options1[] = "<option value='{$d1->id}'>{$d1->area_formacao}</option>";
}
}
elseif($d->tipo=="Não Financiada")
{
$query = "
SELECT `id`, `area_formacao`
FROM `fnfinanciada`;
";
$db->setQuery($query);
$data1 = $db->loadObjectList();
foreach ( $data1 as $d1 ) {
$options1[] = "<option value='{$d1->id}'>{$d1->area_formacao}</option>";
}
}
elseif($d->tipo=="Comparticipada a 75%")
{
$query = "
SELECT `id`, `area_formacao`
FROM `comparticipada`;
";
$db->setQuery($query);
$data1 = $db->loadObjectList();
foreach ( $data1 as $d1 ) {
$options1[] = "<option value='{$d1->id}'>{$d1->area_formacao}</option>";
}
}
elseif($d->tipo=="Empresas")
{
//TO DO
}
else
{
/TO DO
}
?>
<select class="" id="1" size="1" name="1Nivel">
<?php echo implode("\n", $options); ?>
</select>
<select class="" id="2" size="1" name="2Nivel">
<?php echo implode("\n", $options1); ?>
</select>
<select class="" id="3" size="1" name="3Nivel">
<?php echo implode("\n", $options2); ?>
</select>
Actually, is my first time dealing with php.
Best Regards,
Diogo Ribeiro