Hi,
I'd like to hide/show an element as a variable (if ($tt==1){ } ) but I don't know how to do. Could you please help me.
Thank you
I'd like to hide/show an element as a variable (if ($tt==1){ } ) but I don't know how to do. Could you please help me.
Thank you
Hi philphil,
The quick and dirty approach is with CSS. Add this to a Custom Code action in the form OnLoad event
For blocks of elements you can do something similar with containers.
Bob
The quick and dirty approach is with CSS. Add this to a Custom Code action in the form OnLoad event
<?php
$show_me = 'block';
if ( $form->data['some_name'] != 1 ) {
$show_me = 'none';
}
$jdoc = JFactory::getDocument();
$style = ".show_hide { display: '{$show_me}'; } ";
$jDoc->addStyledeclaration($style);
?>
The add the class show_hide to to the element
For blocks of elements you can do something similar with containers.
Bob
Hi Bob,
Thank you very much for your help but the program is not working ! I have changed "$jdoc->addStyleDeclaration" but it's not enough and i'm not sure of the true words.
(excuse my bad english)
Thanks
Thank you very much for your help but the program is not working ! I have changed "$jdoc->addStyleDeclaration" but it's not enough and i'm not sure of the true words.
(excuse my bad english)
Thanks
Hi Bob,
I have made a small form with a Custom Code action in the form OnLoad event with this :
Thank you very much if you have time to help me.
I have made a small form with a Custom Code action in the form OnLoad event with this :
<?php
$form->data['some_name']= 2;
$show_me = 'block';
if ( $form->data['some_name'] != 1 ) { $show_me = 'none';}
$jdoc = JFactory::getDocument();
$style = ".show_hide { display: '{$show_me}'; } ";
$jdoc->addStyleDeclaration($style);
?>
and a container with
Container Class = show_hide
Start Code = <div id='block'>
End Code = </div>
The container is visible (with some_name= 1 or 2) but i'm a beginner and certainly something is missing !
Thank you very much if you have time to help me.
Hi,
there is an easy solution. To do this, two containers must be use with the selection "Custom". Write in the first:
and in the second :
I have found this solution in the forum.
Best regards
there is an easy solution. To do this, two containers must be use with the selection "Custom". Write in the first:
<?php
$display = 'none';
if ( $form->data['some_variable'] == 'no' ) {$display = 'block';}
echo "<fieldset style='display:{$display};' >
<legend>Some Title</legend> ";
?>
and in the second :
</fieldset>
I have found this solution in the forum.
Best regards
This topic is locked and no more replies can be posted.