Buy Now
Sign in

Dropdown to Populate Form

drgolden , June 19 at 13:43
Answered
d
drgolden

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?

admin

Hi drgolden,

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

Best regards,
Max

Max
If your main question got answered then please mark the answer using the button!

d
drgolden

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

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

ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much

d
drgolden

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

Hi drgolden,

Please try

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

Bob

ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much

d
drgolden

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.

d
drgolden

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.