Php access to dropdown text

amitycol 4d ago

Hi, I can easily access the value of a dynamically populated dropdown in PHP (example: $SelectedValue = $this->data("english_language_courses", 9);). How do I access the option text (displayed text) of the dropdown? Example: Selected dropdown item, which has a value of '24' displays 'General English Course'. '$SelectedValue' will return '24'. Now, if I need to assign 'General English Course' to '$SelectedText' what is the correct syntax?

Max_admin 3d ago
Answer
1 Likes

Hi amitycol

This is only possible if you have an array in your PHP code matching values to texts:

$texts = ["24" => "General English Course"];
$selected_text = $texts[$this->data("english_language_courses")];
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
You need to login to be able to post a reply.