• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: Populate fields from DB after dropdown selection

Populate fields from DB after dropdown selection 11 years 6 months ago #25757

  • xferx
  • xferx's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 1
Hi everyone.

This is a tricky one i think. I have:

- Database with the inyecton from a previous Form. This form once submited sends all the information to a TABLE in my database.
- I created a Dropdown field and populate it with the Names and Surnames of the users that have a "yes" on a field "in_process" of my database.
SELECT nIdFormRRHH, nombre, apellido,  opcion_correo, opcion_accesored, opcion_maconomy FROM #__forms_RRHH

- This TABLE also stores other information like: op_correo with the values "yes" or "no".

What i need:

I want a hidden field to load the VALUE "yes" or "no" stored in the TABLE under op_correo for the nIdFormRRHH of the dropdown.

So if this worked it would show a Dropdown that poulates from the database and shows me a name that is "in_process". When i select an item in the dropdown the hidden field takes the VALUE "op_correo" (yes or no) of the same ITEM as the dropdown.

Ths is my code for the Dropdown:
//<code>
// Prepare the empty array
$items = array();
// Prepare the database connection
$db = JFactory::getDbo();
// Keep this if you'd like a "Please select" option, otherwise comment or remove it
$items[] = "|Please Select[c]";
 
// Run the SQL query and store it in $results
$db->setQuery("SELECT nIdFormRRHH, nombre, apellido,  opcion_correo, opcion_accesored, opcion_maconomy FROM #__forms_RRHH");
$results = $db->loadObjectList();
 
// Now, we need to convert the results into a readable RSForm! Pro format.
// The Items field will accept values in this format:
// value-to-be-stored|value-to-be-shown
// Eg. m|M-sized T-shirt
foreach ($results as $result) {
  $value_id = $result->nIdFormRRHH;
  $label_nombre = $result->nombre;
  $label_apellido = $result->apellido;
  $label_opcorreo = $result->opcion_correo;
  $label_opaccesored = $result->opcion_accesored;
  $label_opmaconomy = $result->opcion_maconomy;
  $items[] = $value_id.'|'.$label_nombre.' '.$label_apellido;
}
 
// Multiple values are separated by new lines, so we need to do this now
$items = implode("\n", $items);
 
// Now we need to return the value to the field
return $items;
 
//</code>
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!