Unfortunately, the username and password you have entered do not match!

Registration

Unfortunately, this username is already taken!

Unfortunately, this e-mail address is already used!

Please retype the verification code.

All fields are required

Simple Show/Hide Field Javascript Question

Welcome, Guest
Username Password: Remember me

Simple Show/Hide Field Javascript Question
(1 viewing) (1) Guest
  • Page:
  • 1

TOPIC: Simple Show/Hide Field Javascript Question

Simple Show/Hide Field Javascript Question 1 year, 5 months ago #11167

  • didomi
  • OFFLINE
  • Fresh Boarder
  • Posts: 5
This should be quite simple but I've been scratching my head for some time now!

I've followed this tutorial which gets me to about 90% of where I need to be which is great... www.rsjoomla.com/customer-support/docume...-or-hide-fields.html.

So now I have a form where by clicking on certain radio buttons hides certain fields. But how do I set it up so the default state is to have those fields hidden and clicking on certain radio buttons reveals them?

Here's a snippet of the Javascript I'm using in the form layout box...

 
<script type="text/javascript">
 
function displayStyleOptions() {
 
if(document.getElementsByName('form[style]')[0].checked) {
document.getElementById('hideI').style.display="none"
document.getElementById('hideAtoH').style.display="";
}
 
if(document.getElementsByName('form[style]')[1].checked) {
document.getElementById('hideI').style.display="none"
document.getElementById('hideAtoH').style.display="";
}
 
}


Hope someone can help,
Chris

Re:Simple Show/Hide Field Javascript Question 1 year, 5 months ago #11183

  • bogdanc
  • OFFLINE
  • Moderator
  • Posts: 629
Hello,

You can try setting the script to something like this:

<script type="text/javascript">
 
function displayStyleOptions() {
 
if(document.getElementsByName('form[style]')[0].checked) {
document.getElementById('hideI').style.display="none"
document.getElementById('hideAtoH').style.display="";
}
 
if(document.getElementsByName('form[style]')[1].checked) {
document.getElementById('hideI').style.display="none"
document.getElementById('hideAtoH').style.display="";
}
 
}
displayStyleOptions();
</script>


Let me know if this works for you.

Re:Simple Show/Hide Field Javascript Question 1 year, 5 months ago #11186

  • didomi
  • OFFLINE
  • Fresh Boarder
  • Posts: 5
Solved...I needed to initiate the JavaScript when the form loaded, not simply when the first radio was clicked...

<script type="text/javascript">
displayStyleOptions();
</script>


...simples

Re:Simple Show/Hide Field Javascript Question 1 year, 5 months ago #11188

  • lucrece
  • OFFLINE
  • Fresh Boarder
  • Posts: 3
I did this and got a strange:
id="hide"> id="hide">
now at the top of my form just under the title.

I did this as per the instructions:
The element I am trying to use to determine the conditional is called "Client Pages." In additional attributes I put this code:
onclick="displayField();"

Then in the Form Layout, I inserted this code at the end of the table:
<script type="text/javascript">
function displayField()
{
if(document.getElementsByName('form[Client Pages]')[0].checked)
document.getElementById('hide').style.display="none";

if(document.getElementsByName('form[Client Pages]')[1].checked)
document.getElementById('hide').style.display="";
}
</script>

Then I inserted "id="hide"" into the two elements that I want to be conditional based on the Client Pages radio group.

I don't really understand how this is supposed to be working because the tutorial isn't very clear. Can someone explain?

Re:Simple Show/Hide Field Javascript Question 1 year ago #12692

  • spartan
  • OFFLINE
  • Fresh Boarder
  • Posts: 4
and this code is placed into the default values field of the form field we want to show if the radio button is clicked or does this go into the radio button default values field?

Re:Simple Show/Hide Field Javascript Question 6 hours, 1 minute ago #0

Hello,
This is an automatically generated message.
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 wish to receive our 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: http://www.rsjoomla.com/support-policy.html.

Thank You!
PLEASE NOTE: This topic is NOT locked and you can add replies to it. Other users are free to reply as well. This message has been generated by a bot and has no effect on the topic whatsoever.
  • Page:
  • 1
Moderators: alex, alexp, octavian, bogdanc, andreic
Time to create page: 1.59 seconds
Feedback