Watch the state of a field

madpato

Member
This function i require is also related to this post: http://fabrikar.com/forums/index.php?threads/show-hide-group-based-on-condition.35643/

I need to show parts of a form which depend on what selections have been made on the first tab, please have a look at this form: http://desarrollo.tilatam.com/tns2/index.php/emprendedoress/form/6/

Some of those tabs need to be shown depending on what selections have been made in "proyecto" or "generacion" field. Can you give me some directions on how to achieve this?

Thanks.
 
I've moved this to a new thread, as I don't see how its related. Its best to keep to one issue per thread, as it makes following the converstion easier....
 
Hello i have been trying to do this but i run in to a little problem, i need to check a value which is stored in another list and in the javascript elements i dont see that element related so i tried with a databasejoin element but that its of no use since i need to select the option and i just need to read it from the other table, here is what i need to achieve:

On the Generaciones list i have an element called tipo_generacion which is a dropdown with 3 options level 1, 2 and 3.
Based on those levels i need to show or hide a tab in my "Emprendedores" form, since there are many tabs that i need to show or hide, i just need how i can select this option so i can then use the javascript function.
I have already achieved this but only with elements of the same list, i dont know how to call elements and values from other lists.

Thanks!
 
Well, the short answer is you can't. At least, not without somehow relating (joining) the two lists.

I don't know enough about your setup to help much.

How are those two tables currently related? In other words, you say you want to use data from an element on the Generaiones list, in your Emprendedores form, so how do you know which row in the Generaiones list you need to use?

-- hugh
 
I think this is what you would need to do:
In your emprendedores form, create a calculation element which runs a query to get the tipo element's value for the selected generacion. The calculation element's calculation would need to be something like this:

PHP:
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$generacion = (int) '{tns_emprendedores___tipo_generacion}';
$query->select('tipo_generacion')->from('tns_generaciones')->where('id = ' . $generacion);
$db->setQuery($query);
return $db->loadResult();

Your javascript events can then use the calc element's value.

-Rob
 
Hello Rob

I have tried this on a calc element called: obtener_tipo_generacion but it does not give any result (see it at the bottom of the first tab of the form). Also i have noticed that the variable $generacion was calling the wrong element (i think) it should be:

PHP:
$generacion = (int) '{tns_emprendedores___emp_generacion}';

Since thats the field on my emprendedores form which points to the current selected generation but it still shows nothing, can you help me further?.
Thanks.
 
Try now. I added _raw to that placeholder ...

Code:
$generacion = (int) '{tns_emprendedores___emp_generacion_raw}';

... which is needed because it's a join / CDD, which means the "raw" value needs to be used instead of the display text (label).

-- hugh
 
It shows the desired result now but my event does not work, i have attached a screenshot of what i need to achieve, which is: if the calc element has a certain value hide a specific group (one of the tabs on my form).
I am creating this event on the calc element (maybe thats my mistake).
 

Attachments

  • Capture.PNG
    Capture.PNG
    7.5 KB · Views: 213
For that you are going to need to use a custom js event (we can't blindly hide a possible tab when the group is hidden as a tab may contain more than one group). So some js like:
jsto hide:
JavaScript:
var tab = document.id('group26_tab');
if (typeOf(tab) !== 'null') {
tab.hide();
}
var group = document.id('group9');
if (typeOf(hide) !== 'null') {
hide.hide();
}

js to show:
JavaScript:
var tab = document.id('group26_tab');
if (typeOf(tab) !== 'null') {
tab.hide();
}
var group = document.id('group9');
if (typeOf(hide) !== 'null') {
hide.hide();
}

Its not quiet clear to me how the tab html ids are assigned, so you will need to use firebug in firefox or chrome's inspector to inspect the tab and get the relavant id="groupXX_tab" value.
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top