Hi,
I'm a complete novice with chronoforms,php so please excuse me if I'm asking something which has already been answered before. I've searched the forums but haven't found a tutorial that explains this.
In summary on my form the first item I have is a custom element, a dropdown list of countries which I populate from the database using the following code:
When user selects country and hits submit, I want to populate some text fields on the same form with data associated with the selected country (from the same database table #_chronoforms_data_country_form). I've put a DB record loader event here (is this the correct approach?), also I'm not sure I have configured it correctly! I see a 'request param field' on DB record loader event, how do I tie the value from my dropdown list to this parameter? Is there a tutorial someone can guide me to which can help me understand this.
Thanks, eagerly waiting a response.
I'm a complete novice with chronoforms,php so please excuse me if I'm asking something which has already been answered before. I've searched the forums but haven't found a tutorial that explains this.
In summary on my form the first item I have is a custom element, a dropdown list of countries which I populate from the database using the following code:
<?php
$options = array();
$options[] = "<option value=''>--?--</option>";
$db =& JFactory::getDBO();
$query = "
SELECT `code`, `name`
FROM `#_chronoforms_data_country_form`
ORDER BY `name`;
";
$db->setQuery($query);
$data = $db->loadObjectList();
foreach ( $data as $d ) {
$options[] = "<option value='{$d->code}'>{$d->name}</option>";
}
?>This works fine and I see my list of country names in the drop down list, beside the list I have a submit button.When user selects country and hits submit, I want to populate some text fields on the same form with data associated with the selected country (from the same database table #_chronoforms_data_country_form). I've put a DB record loader event here (is this the correct approach?), also I'm not sure I have configured it correctly! I see a 'request param field' on DB record loader event, how do I tie the value from my dropdown list to this parameter? Is there a tutorial someone can guide me to which can help me understand this.
Thanks, eagerly waiting a response.
Hi moshiani,
I'm not clear what you want to do here. You say that you want to display results in the same form after the user clicks submit. That's possible, but more often you either (a) go to a second form and display the results there or (b) use JavaScript or Ajax to display the results when the the drop-down country election changes.
Bob
I'm not clear what you want to do here. You say that you want to display results in the same form after the user clicks submit. That's possible, but more often you either (a) go to a second form and display the results there or (b) use JavaScript or Ajax to display the results when the the drop-down country election changes.
Bob
Thanks for your response and suggestion. I have now split this over two forms, the first one has a dropdown list of countries and the second one has country information.
In the first form (with the dropdown list) do I put the Load JS event on the OnLoad event? I did this but it doesn't seem to load the second form when the dropdown list changes.
In the first form (with the dropdown list) do I put the Load JS event on the OnLoad event? I did this but it doesn't seem to load the second form when the dropdown list changes.
Hi moshiani ,
What JavaScript have you put into the Load JS box? There hasn't been any in this thread. And how is that going to help you get the Country information?
Bob
What JavaScript have you put into the Load JS box? There hasn't been any in this thread. And how is that going to help you get the Country information?
Bob
This topic is locked and no more replies can be posted.
