• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: How to hide textbox not after checking chechbox

How to hide textbox not after checking chechbox 13 years 11 months ago #10541

  • Oleg
  • Oleg's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 1
Hi everyone!

I've read this topic in the tutorial (www.rsjoomla.com/customer-support/docume...-or-hide-fields.html) and now I can show or hide some textbox AFTER clicking on radio component.
But my question is: can I hide some textbox NOT AFTER clicking on radio component BUT BEFORE such clicking.
For example, let’s suppose that my radio component is named: "Radio" with the following configuration:

Items:
val1|Description1
val2|Description2
(and both of this items are NOT selected in the initial state of the form).
And suppose that I have two textboxes “Textbox1” and “Textbox2”.
I wish in the first opening of the form to be only radio group “Radio” with two unselected items: val1 and val2 (and two hidden textboxes).
And only after I’ll select one of the radio item, the appropriate textbox will be shown (“Textbox1” if I’ll select val1 and “Textbox2” if I’ll select val2).
Can someone help me to hide textboxes in the opening of the form?
Thank you in advance!
Sorry for my English.
The administrator has disabled public write access.

Re:How to hide textbox not after checking chechbox 13 years 11 months ago #10569

  • andreic
  • andreic's Avatar
  • OFFLINE
  • RSJoomla! Official Staff
  • Posts: 733
  • Thank you received: 60
Hello,

In order to achieve this you could try changing the script so that the fields will be hidden when the page is loaded and only show them when the correct radio option is selected. The script should be similar to:
<script type="text/javascript">
 
function displayField()
{
document.getElementById('hide1').style.display="none";
document.getElementById('hide2').style.display="none";
 
if(document.getElementsByName('form[radio_group_name]')[0].checked)
{
document.getElementById('hide1').style.display="";
}
 
if(document.getElementsByName('form[radio_group_name]')[1].checked)
{
document.getElementById('hide2').style.display="";
}
</script>

In order to hide the fields when the page is loaded you should add the following script after your already existing code found in the "Form Layout" tab:
<script type="text/javascript">
displayField();
</script>
Please note: my help is not official customer support. To receive your support, submit a ticket by clicking here
Regards,
RSJoomla! Development Team
The administrator has disabled public write access.

Re:How to hide textbox not after checking chechbox 13 years 8 months ago #11194

  • lucrece
  • lucrece's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 3
Anyone gotten this to work?
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!