Hello,
I have a form, that I like to load with data from a database when I change a value from
the dropdown box
I load the dropdown dynamic from a table where the onChange calls a function load_data_on_form($sel_user_id)
And there is the problem, in that function I can load new data from a table
But how can I load then that data on the form
I have some text fields on the form user_id,bedrijfsnaam,naam,straat,...
How to load now the value from the database on the form ?
form-->data ?? = $data->user_id;
form-->data ?? = $data->bedrijfsnaam;
I have a form, that I like to load with data from a database when I change a value from
the dropdown box
I load the dropdown dynamic from a table where the onChange calls a function load_data_on_form($sel_user_id)
And there is the problem, in that function I can load new data from a table
But how can I load then that data on the form
I have some text fields on the form user_id,bedrijfsnaam,naam,straat,...
How to load now the value from the database on the form ?
form-->data ?? = $data->user_id;
form-->data ?? = $data->bedrijfsnaam;
<?php $options = array(); $options[] = "<option value=''>Select Debiteur</option>"; $db =& JFactory::getDBO(); $query = " SELECT `id`, `name` FROM `#__users` ORDER BY `name`; "; $db->setQuery($query); $data = $db->loadObjectList(); foreach ( $data as $d ) { $options[] = "<option value='{$d->id}'>{$d->name}</option>"; } ?> <select class="" id="user_id" size="1" name="User_Name" onChange="load_data_on_form(id)"> <?php echo implode("\n", $options); ?> </select> <?php function load_data_on_form($sel_user_id) { $db =& JFactory::getDBO(); $query = " SELECT `user_id`, `bedrijfsnaam`, `naam`,`straat` FROM `#__user_detail` ORDER BY `naam`; WHERE user_id =`$sel_user_id` "; $db->setQuery($query); $data = $db->loadObjectList(); form->data ... = $data->user_id; form->data ... = $data->bedrijfsnaam; form->data ... = $data->naam; form->data ... = $data->straat; } ?>