• 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: On click show 2 fields

On click show 2 fields 13 years 8 months ago #11419

  • parelweb
  • parelweb's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 13
Hi,

I'm a really newbe into javascript and probally this is one of the most simple quetsions.

I'm making a form on a website. On selection of "yes" in one field two hidden fields must become visible. I managed to get it worked with one field but the sceond one wont work.

I've made it this far:

The attribute on the field "lint" is: onclick="displayField();"

The script i use is:
<script type="text/javascript">
function displayField(field)
{
if(document.getElementById('lint').value == 'Ja')
document.getElementById('lint_kleur').style.display="";

else {
document.getElementById('lint_kleur').style.display="none";
document.getElementById('lint').value="";
document.getElementById('helement').setAttribute("class", "formNoError");
}
}

function validateFields()
{
if(document.getElementById('lint').value == 'Ja' && document.getElementById('Nee').value == '')
{
document.getElementById('lint_kleur').setAttribute("class", "formError");
return false;
}
else
return true;
}

window.addEvent('domready', function() {
displayField();
});
</script>

In this case when the field "lint" is set to "Ja" the field "lint_kleur" becomes visible. I also have a field called "lint_afscheid" that has to become visible when the field "lint" is set to "Ja".

Can someone help me a little further?

Thanks,
Hans
The administrator has disabled public write access.

Re:On click show 2 fields 13 years 7 months ago #11436

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

From what I can see you only have the conditions for one field, you will need to add the second field as well, for example:
if(document.getElementById('lint').value == 'Ja'){
document.getElementById('lint_kleur').style.display="";
document.getElementById('lint_afscheid').style.display="";
}
else{
document.getElementById('lint_kleur').style.display="none";
document.getElementById('lint_afscheid').style.display="none";
document.getElementById('lint').value="";
document.getElementById('helement').setAttribute("class", "formNoError");
}
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 7 months ago by andreic.
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!