• 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: Autopopulate based on another field

Autopopulate based on another field 2 years 7 months ago #41566

  • brian905
  • brian905's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 3
Ok,

here is what I have going on.

I am pulling information from a local database and using the mapping method writing the data after submission.

I have a second form that is going to populate the data. I have the php to populate the dropdown, but am having trouble getting the code to query the right column/row. the selector is the full name then it pulls their email and payrate to 2 other fields.

//<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 FirstName, LastName FROM your___database___name");
$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 = $result->FirstName . ' ' . $value = $result->LastName;
$label = $result->FirstName . ' ' . $label = $result->LastName;
$items[] = $value .'|'. $label;
}

// Multiple values are separated by new lines, so we need to do this now
//output = array_merge($items1, Items2);

// 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!