How to display a field depending upon other field.

ab185178
Contributor
December 1, 2011

I am trying to display a Label type field only on the condition that the Issue type is Inspection Defect. This is the code that I am using:

<script type="text/javascript">
issuetype = document.getElementByName('issuetype');
if (issuetype)
{ target = document.getElementById('customfield_11200'); // Hide the target field if issuetype not Inspection Defect
if (issuetype.value != 7)
{ target.style.display='none';
}
else
{ target.style.display='inline';
}
}
</script>

Please let me know if I need to change anything.

2 answers

1 accepted

0 votes
Answer accepted
Pascal Collard December 1, 2011

Hi;
Are you sure getElementByName is compatible with the browser? It's not a native function for all browsers.
Maybe ujse jQuery to be more cross-browser compatible? Will be easier for you to hide/show the element too.

0 votes
Jobin Kuruvilla [Adaptavist]
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.
December 1, 2011

In JIRA 4.4, you can do something like this:

&lt;script type="text/javascript"&gt;
if (AJS.$("input[name=issuetype]").val() != 1){
 AJS.$(".aui-field-labelpicker").hide();
}
&lt;/script&gt;

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events