Hide or Show element

jacardiel

New Member
Hi,
i have an image element ("Reservar"). I want hide or show it, depend on the value the field "reservado" has.
If reservado='S' then the image element "Reservar" should hide, and if reservado='N' then show, but I don't achieve thet work well.

I Attach the configuration of this element.

Thanks
 

Attachments

  • reservar.png
    reservar.png
    88.3 KB · Views: 198
It's vice versa: you must add the JS to your Reservado element
hide reservar (= the image element) if this (=element Reservado) == 'S'
 
OK now work well when I load the form, but not work well in a list.
I call to list from a item k2.{fabrik view=list id=5 cachorros___id_camada=2 layout=default}
What is the problem in the list?
 
The JS settings of the element won't work in the list.
You should use a "calc" element to display the path of your "reservar" image based on the value of the other element.
 
Hi,
i install the calc plugin and i add a new calc element at the same table. I write the next code, but don't work well. What is the problem?

if ($cachorros___reservado=='N')
{
$cachorros___reservar=='images/reservar_cachorro.jpg';
}
else
{
$cachorros___reservar=='';
}
Thanks
 
You need to use PHP in the calc element (more info in the wiki) so something like this:
Code:
if ('{cachorros___reservado}' == 'N')
return "images/reservar_cachorro.jpg";
else return "";
 
Ok, with this code I obtein the right value depend on the element reservado, but How assign I this value to the image element "reservar" for show or not the image?

Something like this don't work

if ('{cachorros___reservado}' == 'N')
'{cachorros___reservar}'=="images/reservar_cachorro.jpg";
else '{cachorros___reservar}'=="";

Thanks
 
Try this :
Code:
if ('{cachorros___reservado}' == 'N') {
return '<img src="images/reservar_cachorro.jpg">';
} else {
 return ' ';}
 
In edit view, the JS code in the JS tab of the element should do the trick.
When you say it does not work in form, I guess you mean detail view.
For that you need to edit/save the record so the value of the calc is recorded in the database (otherwise it is displayed in the list "on the fly" via Ajax). Once it is recorded in the database, it should be displayed in the detail form also (I think it used not to, but this was corrected some time ago).
 
In the list work properly.
Whe i say form, I want to say detail view how you well guess.
I attach two images, in olist view you can show that the element calc "prueba" work well depending on the reservado value, but in detail view, not,
If i edit the detail view ad save, the list refresh well but when i access to detail not. Any idea?

Thanks
 

Attachments

  • list.png
    list.png
    25 KB · Views: 140
  • detail_form.png
    detail_form.png
    87.7 KB · Views: 156
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top