Dynamic Drop Down From DataBase

atanunu 14 Aug, 2015
Sir,

Please, I need help in creating a DYNAMIC drop down.

I have a database table with three columns (id, lga, state) and a form with STATE and LOCAL GOVERNMENT drop down. I want to load the Local Government based on the selection made in the STATE field.

Here is a sample code I used.

<?php
$results = array();
$results[] = '=??';
foreach ( $form->data['State'] as $v ) {
  $results[] = $v['lga'].'='.$v['lga'];
}
$results = implode("\n", $results);
echo $results;
$mainframe =& JFactory::getApplication();
$mainframe->close();
?>


I have attached screen shot of the EVENTS / FORM / DATABASE
atanunu 18 Aug, 2015
Please, I could not setup what I wanted using the procedures above.

Help!!!
atanunu 19 Aug, 2015
Using the following code I am able to output the array from the table and it displays on the page but does not load on the form.

<?php
$lga = array();
if ( !$form->data['Data'] || count($form->data['Data']) < 1 ) {
  // no result was found
  $options[] = 'Please select a State';
} else {
  foreach ( $form->data['Data'] as $d ) {
    $lga[$d['lga']] =  $d['lga'];
  }
}
echo json_encode($lga);
?>


I had used a DB Read action and an the code below to output the result

<?php
return array( 'State' => $form->data['State']);
?> 


If I access the page from the url e.g I get actual intended results
http://server.esebun.com/Admission/UTMEConfirmation.aspx?State=Akwa%20Ibom

Kindly assist
GreyHead 19 Aug, 2015
Hi atanunu,

Please post a link to the form so I can take a quick look.

Bob
atanunu 19 Aug, 2015
Sir, here is the link to the form http://server.esebun.com/Admission/UTMEApplication.aspx
GreyHead 21 Aug, 2015
Hi atanunu,

I don't see the JavaScript on the page to run an Ajax request linked to the Country drop-down.

Bob
atanunu 23 Aug, 2015
Sir,

I had to change the option to autocompleter instead of drop down option. I will redress and ask for help again.

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