Forums

Dropdown to Populate Form

drgolden 19 Jun, 2017
I have a dropdown box populated through a db query. I want the selection from this dropdown to populate a form based on a db read. Reading through the forums, etc. it seems like this solution is evident to almost everyone except myself.

I have been through the forums, tutorials etc and still don't quite understand how to do this and need to get the project off my desk . I can easily post webpages up and provide access.

Any help out here?
Max_admin 19 Jun, 2017
Hi drgolden,

You want 1 dropdown to populate multiple fields from the database, correct ?

Best regards,
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
drgolden 19 Jun, 2017
Yep. The dropdown lists the names of the forms submitters. I want to create the for a reviewer to select the name, have to form populate and allow a review of the entire form.

I have the dropdown working, it's just getting the down select to populate the form fields.
GreyHead 19 Jun, 2017
Hi drgolden,

I would do this with a two page form - have the drop-down on the first page with a Next button, then have the main form on the second page and use a DB Read action together with the name from the first page to load the selected record.

Bob
drgolden 19 Jun, 2017
Hi Bob-

I know this is extremely simple, but formulating the DB Read action is where I get hung up.

On page 1 the dropdown (dropdown2) contains the value of ecname field.

I am assuming that I need to get the selected value of (dropdown2) and input it into the condition statement of DB Read:

<?php return array('ecname' => '[dropdown2]'); ?> .

I can't find how to specifiy the selected dropdown value in the conditions statement.
GreyHead 19 Jun, 2017
Answer
Hi drgolden,

Please try
<?php
return array( 'ecname' => $form->data['dropdown2'] ) ;
?>

Bob
drgolden 19 Jun, 2017
Hi Bob-

So when I go to the second page, the debugger shows the proper data array. The debugger shows the correct data for the query and the field ecname in debugger array is correct.

However, the text box on that page with field id and field name set to ecname does not populate.

Perhaps the setup sequence for page 2 is incorrect/incomplete ?

(after on submit)
On Page 2
Multipage
DB Read
HTML Render Form
Debugger

Just bought you a cuppa. Hope that helps a bit.
drgolden 19 Jun, 2017
Just found the problem. All is good. The DB Read was set Yes to Model ID. When set to No the form populates correctly.

Thanks for your help.
This topic is locked and no more replies can be posted.