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.
I have attached screen shot of the EVENTS / FORM / DATABASE
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
Hello does this help you?
http://www.chronoengine.com/faqs/63-cfv4/cfv4-working-with-form-data/3222-how-can-i-get-useful-data-from-select-drop-downs-checkboxes-and-radio-buttons.html
http://www.chronoengine.com/faqs/70-cfv5/5232-how-do-i-build-a-dynamic-drop-down-in-cfv5.html
http://www.chronoengine.com/faqs/70-cfv5/5209-how-to-debug-database-queries.html
http://www.chronoengine.com/faqs/63-cfv4/cfv4-working-with-form-data/3222-how-can-i-get-useful-data-from-select-drop-downs-checkboxes-and-radio-buttons.html
http://www.chronoengine.com/faqs/70-cfv5/5232-how-do-i-build-a-dynamic-drop-down-in-cfv5.html
http://www.chronoengine.com/faqs/70-cfv5/5209-how-to-debug-database-queries.html
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.
I had used a DB Read action and an the code below to output the result
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
<?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
Sir, here is the link to the form http://server.esebun.com/Admission/UTMEApplication.aspx
Hi atanunu,
I don't see the JavaScript on the page to run an Ajax request linked to the Country drop-down.
Bob
I don't see the JavaScript on the page to run an Ajax request linked to the Country drop-down.
Bob
This topic is locked and no more replies can be posted.