• 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: I want to show hide multiple fields with one radio

I want to show hide multiple fields with one radio 13 years 6 months ago #11674

  • mark69
  • mark69's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 1
Here is the code i am using i cant figure out what is wrong please help


<script type="text/javascript">

if(document.getElementsByName('form[Attending]')[0].checked)
{
document.getElementById('helement').style.display="none";
document.getElementById('hGuest').style.display="none";
}

if(document.getElementsByName('form[Attending]')[1].checked)
{
document.getElementById('helement').style.display="";
document.getElementById('hGuest').style.display="";
}
</script>
<div class="componentheading">{global:formtitle}</div>
{error}
<table border="0">

<tr>
<td>{Name:caption}</td>
<td>{Name:body}</td>
<td>{Name:validation}</td>
<td>{Name:description}</td>
</tr>
<tr>
<td>{Email:caption}</td>
<td>{Email:body}</td>
<td>{Email:validation}</td>
<td>{Email:description}</td>
</tr>
<tr>
<td>{Attending:caption}</td>
<td>{Attending:body}<div class="formClr"></div>{Attending:validation}</td>
<td>{Attending:description}</td>
</tr>
<tr id="helement">
<td>{Lunch:caption}</td>
<td>{Lunch:body}<div class="formClr"></div>{Lunch:validation}</td>
<td>{Lunch:description}</td>
</tr>
<tr id="hGuest">
<td>{Guest:caption}</td>
<td>{Guest:body}<div class="formClr"></div>{Guest:validation}</td>
<td>{Guest:description}</td>
</tr>
<tr>
<td>{Submit:caption}</td>
<td>{Submit:body}<div class="formClr"></div>{Submit:validation}</td>
<td>{Submit:description}</td>
</tr>

</table>
The administrator has disabled public write access.

Re:I want to show hide multiple fields with one radio 13 years 6 months ago #11699

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

Please try using :
if(document.getElementById('Attending0').checked)
{
 document.getElementById('helement').style.display="none";
 document.getElementById('hGuest').style.display="none"; 
}
Please note: my help is not official customer support. To receive your support, submit a ticket by clicking here
Regards,
RSJoomla! Development Team
Last Edit: 13 years 6 months ago by andreic.
The administrator has disabled public write access.

Re:I want to show hide multiple fields with one radio 13 years 2 days ago #13544

  • bmdesign
  • bmdesign's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 1
Hm i'm trying to show different fields with each radio button so i tried to do
if(document.getElementById('Attending0').checked)
{
document.getElementById('helement').style.display="";
document.getElementById('hGuest').style.display="none";
}
else if(document.getElementById('Attending1').checked)
{
document.getElementById('helement').style.display="none";
document.getElementById('hGuest').style.display="";
}
but it doesn't work, it just shows both fields like it would break the code, what do I do wrong?

EDIT: stupid me, it works, I just forgot to add the brackets ...
Last Edit: 13 years 2 days ago by bmdesign.
The administrator has disabled public write access.

Re:I want to show hide multiple fields with one radio 12 years 5 months ago #15608

Hello, I am having the same issue also, were you able to solve yours? And if so, can you share your code with me so that I may do the same with my form?

Thank You
Joseph
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!