• 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: hiding more than one field at a time

hiding more than one field at a time 15 years 9 months ago #7819

If anyone has any advice or help. I'm trying to hide more than on field on a form at a time however I cant seem to figure out how to do so. I use the below script and can get one form to hide but I'm rather new to this and could use some help. THanks in advance!

<script type="text/javascript">
function displayField()
{
if(document.getElementsByName('form[radio]')[0].checked)
document.getElementById('hide').style.display="";

if(document.getElementsByName('form[radio]')[1].checked)
document.getElementById('hide').style.display="none";
}
The administrator has disabled public write access.

Re:hiding more than one field at a time 15 years 9 months ago #7831

Anyone?
The administrator has disabled public write access.

Re:hiding more than one field at a time 15 years 9 months ago #7844

  • bogdanc
  • bogdanc's Avatar
  • OFFLINE
  • Moderator
  • Posts: 669
  • Thank you received: 11
Hello,

Create a formthat contains a text box and a radio groupt. The radio box, should be named "Radio" so that it has the same name as the form[Radio] from the script. Note that you can change the name of the radio group, but if you do make sure you change it in the script also. Note you will be able to add more conditions to the script but make sure you use the correct id's in the script. Also in the additional attributes box you will have to add:
onclick="displayField();"

After that create a text box named "hide".

Now make sure you have added all the other items you want to add to the form. Unclick the "Auto Generate Layout" option and paste and the end of the layout this script:
<script type="text/javascript">
function displayField()
{
if(document.getElementsByName('form[Radio]')[0].checked)
document.getElementById('hide').style.display="none";
 
if(document.getElementsByName('form[Radio]')[1].checked)
document.getElementById('hide').style.display="";
}
</script>

Now when you select the first item of the radio box the text box should be hidden, and when you select the 2nd item in the radio box the text box should appear.

Regards!
The administrator has disabled public write access.

Re:hiding more than one field at a time 15 years 9 months ago #8079

Thanks for the update. Can you assist further? I'm trying to hide more than one field at once and I'm not sure what I am doing wrong This is what i've tried


{
if(document.getElementsByName('form[radio]')[1].checked)
document.getElementById('hide').style.display="none";
document.getElementById('hide1').style.display="none";

if(document.getElementsByName('form[radio]')[0].checked)
document.getElementById('hide').style.display="";
document.getElementById('hide1').style.display="";
}
</script>
The administrator has disabled public write access.

Re:hiding more than one field at a time 15 years 8 months ago #8144

  • alexp
  • alexp's Avatar
  • OFFLINE
  • RSJoomla! Official Staff
  • Posts: 2253
  • Thank you received: 180
Hello,

Please note that you have to use brackets for multiple instructions to be executed inside a "if" clause:
if(document.getElementsByName('form[radio]'[1].checked)
{
document.getElementById('hide').style.display="none";
document.getElementById('hide1').style.display="none";
}
if(document.getElementsByName('form[radio]'[0].checked)
{
document.getElementById('hide').style.display="";
document.getElementById('hide1').style.display="";
}
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.
  • 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!