Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

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

Manuel Campomanes
Contributor
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
Contributor
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
TAGS
atlassian, mindful member, mindful member badge, atlassian community, community kudos, community giveaway, atlassian swag, community values, empathy and kindness, badge challenge, atlassian learning, community engagement, swag giveaway

Earn a Badge, Win a Prize 🎁

Earning the Mindful Member badge proves you know how to lead with kindness, plus it enters you into a giveaway for exclusive Atlassian swag. Take the quiz, grab the badge, and comment on our announcement article to spread the good vibes!

Start here
AUG Leaders

Atlassian Community Events