Hide Text field/area dependent on a checkbox/radio button

oracle 08 Mar, 2014
Hello all,
two senarios. I saw your FAQ to show/hide fields but its not working for me :-(

1. I want to hide/show a text field dependent on a radio button (see attached scressnhot 2.jpg)

2. I want to hide/show a text area dependent on a special checkbox in a checkbox-group (see attached screenshot 1.jpg)

regards,
oracle
GreyHead 09 Mar, 2014
Hi oracle,

There's no useful information here. Please post the JavaScript you have used and the ids of the inputs involved.

Bob
oracle 09 Mar, 2014
Hi Bob,

I want to hide/show a text field (in this case a date picker field) dependent on a radio button.
If i select the radio button "ja" the text field (date picker) should be visible. If i select "Nein" it should be hidden.

1. I add the Field Id "radio1" to the radio button field and Field Id "date1" to the datetime picker.
2. I create a "Load JS" Event and add this

(http://www.chronoengine.com/faqs/58-cfv4/cfv4-elements-and-html/2645-how-can-i-showhide-a-textarea-when-a-checkbox-is-clicked.html)

LOAD JS
var checkbox_id, textarea_id, checkbox, textarea, div;
/* edit the next two lines to match the ids of the elements in your form */
checkbox_id = 'radio1';
textarea_id = 'date1';

window.addEvent('domready', function() {
  checkbox = $(checkbox_id);
  textarea = $(textarea_id);
  div = $(textarea_id+'_container_div');
  div.dissolve();
  showHide();
  checkbox.addEvent('click', showHide);
});

function showHide() {
  if ( checkbox.checked ) {
    div.reveal();
    textarea.disabled = false;
  } else {
    div.dissolve();
    textarea.value = '';
    textarea.disabled = true;
  }
}
oracle 10 Mar, 2014
Hi again,

if i open the "test form" page its working! But on my website not :-(
Is there a javascript conflict?

regards,
oracle
oracle 10 Mar, 2014
Hi again,

i get this error
GreyHead 11 Mar, 2014
Hi oracle,

Is the MooTools More library being loaded on your page? Please post a link to the form so I can take a quick look.

Bob
oracle 11 Mar, 2014
http://aerorefund.com/flug-verspätet.html

Please delete the link after your check thanks oracle
GreyHead 11 Mar, 2014
Hi oracle,

In the JavaScript the checkbox id is shown as checkbox1 - but I don't' see any checkbox with this ID in the form. I also didn't find the 'dissolve' error??

Bob
oracle 11 Mar, 2014
Hi Bob,
sorry i have changed the Checkbox to a Checkbox Group. In the Checkbox Group i have added the ID "checkbox2". If you flag the Checkbox "Anderer Grund" the textarea should be visible. Can you help me here?

I have added the normal Checkbox with id "checkbox1" again for testing!

best regards,
oracle
oracle 14 Mar, 2014
Hi Bob,

can you please have a short look... Thanks

regards,
oracle
GreyHead 28 Mar, 2014
Hi oracle,

I found the form but now don't see the JavaScript on the page at all.

Bob
This topic is locked and no more replies can be posted.