Show textbox after dropdown

Show a textbox after selecting a value in a dropdown.

Overview

The issue occurs when trying to display a textbox based on a selection from a dropdown populated via AJAX, as the initial AJAX code only sets dropdown options, not field values.
Use the "Set dynamic value" event in CFv5.0.6 or later to dynamically set the textbox value after the AJAX request. Ensure the target field is not inside a multi-field container, as that can prevent the event from working.

Answered
dm dmiao83 14 Feb, 2015
Hi, sorry for my english. I'll show a textbox after selected 4th value in a 4 different dropdowns. the dropdowns they're populated with ajax's events, with out problem :mrgreen: .
I tried in this way, with out results 😢 😢 😢 😢 :

In 4th dropdown events is: ON != (empty) Set Dynamic options check ajax4

On ajax4

<?php
$d1 = 'Dettagli di viaggio già caricati';
$d2 = 'Dettagli di viaggio non ancora caricati';
$var1 = JRequest::getVar('scuola','', 'get');
$var2 = JRequest::getVar('progetto','', 'get');
$var3 = JRequest::getVar('anno','', 'get');
$var4 = JRequest::getVar('nomprog','', 'get');

$query = "SELECT uniq_id FROM #__a_ammin WHERE id_scuola='$var1' && id_cod='$var2' && id_anno='$var3' && n_prog='$var4'";
$db =& JFactory::getDBO();
$db->setQuery($query);
$row = $db->loadAssoc();
$a = $row['uniq_id'];

$query2 = "SELECT id_viag FROM #__a_d_viag";
$db =& JFactory::getDBO();
$db->setQuery($query2);
$row2 = $db->loadAssoc();
foreach ($row2['id_viag'] as $g){
	if ($g['id_viag'] == $a) {
		$form->data['check'] = $d1;
		}
		else {
		$form->data['check'] = $d2;
			}
}
echo json_encode($form->data['check']);
?>


Best regards

Domenico
Max_admin Max_admin 14 Feb, 2015
Hi Domenico,

the problem is with returning the results or with showing the textbox ?

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
dm dmiao83 14 Feb, 2015
Hi Max,

I'll want show value of d1 or d2 in textbox... but if I use:
$results = $d1;
....
$results = $d2;
.....
echo json_encode($results);...

don't showing the value in textbox (check)

Regards
Domenico
Max_admin Max_admin 15 Feb, 2015
1 Likes
Hi Domenico,

The code you have will set the options list of a dropdown field, but it will not set a field's value.

In order to set a field value you need to do an AJAX call using code, but I will try to add a new event to set a field value and include it in the new update scheduled for today!

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
dm dmiao83 18 Feb, 2015
Hi Max,
I upgraded CFv5 e CCv5... But I don't understand better. Which event I should to use???


Regards
Domenico
Max_admin Max_admin 18 Feb, 2015
Answer
1 Likes
Hi Domenico,

The latest v5.0.6 has a new field event named "Set dynamic value" which can be used to set a field's value dynamically after an AJAX request.

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
dm dmiao83 18 Feb, 2015
Hi Max,

Work it!. If a dropdown or textbook or... is inside a "multi field" it is not possible to set the event.

Regards,
Domenico
Max_admin Max_admin 19 Feb, 2015
The multi field issue has been fixed and is ready for the next update, but what's the "dropdown or textbook" ??
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.