help faq How do I build a select drop-down, radio button

jonnyblog1976 11 Jan, 2013
Hello to all,
I do not speak English very well, so forgive any errors
in the faq http://www.chronoengine.com/faqs/2647-how-do-i-build-a-select-drop-down-radio-button-or-checkbox-group.html in the example Double drop-down with Ajax
how should be configured the first drop-down? i made so:
tab general
Label Text: categories
Field Name: categories
Field id: categories
the rest unchanged
tab Dynamic Data
Enable: yes
Data Path: joscategories
Value Key: id
Text Key: title

and the first DB Multi Record Loader in the ON LOAD EVENT? i made so:
Table: jhost_categories
Model ID: joscategories
Fields: id,title

the Dynamic Drop Down action in the ON LOAD EVENT? i made so
Action Label: ajax
Source Dropdown ID: categories
Target Dropdown ID: articles.

it is correct?
jonnyblog1976 11 Jan, 2013
i' m using chronoforms V4 e joomla 2.5. thanks
GreyHead 12 Jan, 2013
Hi johnnyblog1976,

Most of this looks good except that you do not have a second 'articles' drop-down listed here.

Bob
jonnyblog1976 12 Jan, 2013
Hi Bob,
sure, this is only the first step...
the second Drop Down is:

tab general
Label Text: articles
Field Name: articles
Field id: articles
the rest unchanged
tab Dynamic Data
Enable: yes
Data Path: josarticles
Value Key: id
Text Key: title

and at the end the part most important: the ajax event!

-DB Multi Record Loader in the ajax event:
Table: jhost_content
DB Field: catid
Request Param: categories
Model ID: articles
Fields: id,title

- a custom code action (with the code show in the exemple)

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

is all correct?

after doing that in the second drop down i see failed loading... why?
Thank you.
Jonny
GreyHead 13 Jan, 2013
Hi jonnyblog1976 ,

Again it all looks OK but there could easily be a little bug in there somewhere.

At his stage I'd use my web developer tools to see exactly what is being returned from the Ajax call. You can also temporarily add debug code in the Custom Code action there to see the results array. The Net Tab in FireBug for FireFox is good for this - other browsers have similar tools.

Bob
jonnyblog1976 14 Jan, 2013
Hi Bob,
my doubt is: the second Drop Down Dynamic Data must be set to yes? or set to no? or is irrelevant?
i'm looking for debuging.
Thank you very much for your answers
Jonny
GreyHead 14 Jan, 2013
Hi Jonny,

There is no options list so you are setting the values dynamically so it must be set to Yes and correctly configured.

Bob
jonnyblog1976 14 Jan, 2013
Ok Bob,
probably i don't understand very well what ajax event do,
but i think that the josarticles array is empty, that is correct?
there isn't any db multi record loader that put any information inside it...
is the ajax event that put information inside the drop down, is correct?
GreyHead 14 Jan, 2013
Hi Jonny,

Yes, the Ajax event needs to have a DB Multi-Record loader to get the records followed by a Custom Code action to format them and send them back to the browser.

Bob

PS You could combine both in the Custom Code action if you are OK writing a MySQL query for Joomla!
jonnyblog1976 14 Jan, 2013
Thanks for help.Now all working good.
I find the error, it was in the ajax custom code.
And the code work with the second drop down Dynamic data set to yes,
but it also work with the second drop down Dynamic data set to no... ????
Bye
This topic is locked and no more replies can be posted.