How I can hide a datepicker field according to another field value ?

Manuel Campomanes March 6, 2012

Hello,

I need to hide or not a "date and hour" field, I try the JS function (http://confluence.atlassian.com/display/JIRA/Displaying+a+Field+Based+on+Another+Field+Selection), but it only hide the text area and not the label and the datepicker.

A schema to explain what I have (left side) and what I need (right side) :

JS code :

<script type="text/javascript">
  source = document.getElementById('customfield_10600');
  if (source) {
      target = document.getElementById('customfield_10601');
      if (source.value == 'Oui') target.style.display='none';
 
      source.onchange=function() {
          if (this.value == 'Oui') {             
                     target.style.display = '';      
                  } else {
                 target.style.display='none';
          }
      }
  }
 </script>

1 answer

1 accepted

1 vote
Answer accepted
Radek Kantor
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 6, 2012

Hi, take the parent ot an element with id="customfield_10601", should be some <div/> and disable it.

Manuel Campomanes March 6, 2012

YEAH !

Just need to modify the target :

 target = document.getElementById('customfield_10601').parentNode;

Suggest an answer

Log in or Sign up to answer