How to use a drop down to dynamically change form data

DShapiroNaples 27 Jan, 2011
I am looking for suggestions on how to best handle the following situation:

1. The user will be presented with a dropdown of all registsred user names as the first field of a chronoform.
2. After the user selects a particular name from the dropdown I want to check a database table for a row where there is a matching joomla user id (Note: The joomla user id will be the primary key). If there is a matching row then the fields from that need to fill in the chronoform so the user can then edit the data.
3. If the user then changes the dropdown I want to be sure to write any edits (or insert new record, if the user did not have an existing record) back into the database before the newly selected users data is displayed

How would you suggest that this be accomplished.
GreyHead 30 Jan, 2011
Hi DShapiroNaples,

I'd do this with two linked forms. The first one with the drop-down and the next with the values to edit.

I don't undertand how point 3 works though? Is it that they change their selection from one user to another? That would work with a DB Connection on form 1.

Bob
DShapiroNaples 01 Feb, 2011
Thanks for the reply. I am not sure what you mean by "linked" forms. Are you talking about a parent with two children?

What type of code do I need to put in place to switch from form 1 to form 2 after the dropdown selection has been made?
GreyHead 02 Feb, 2011
Hi DShapiroNaples,

There are various ways you could do it but I think I'd start out with the first form having the URL of the second form in the OnSubmit URL box, that should pass over the User Name to the second form. You can pick it up in the Form HTML there and use it to select the data you need. Assuming the name of the select box in Form 1 is 's_user' this should do it:
<?php
$s_user = JRequest::getInt('s_user', 0, 'post');
?>


Bob
This topic is locked and no more replies can be posted.