Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to hide a checkbox custom field?

Jan Post July 10, 2011

Using html/jquery in the description field enables hiding of text fields, and checkbox elements.The lines below enable me to hide/show checkbox values.

<script type="text/javascript">
if( AJS.$("#customfield_10280-1").attr('checked') && AJS.$("#customfield_10280-2").attr('checked'))
{ AJS.$("#customfield_10281-1").closest('div.checkbox').show();
}
else
{ AJS.$("#customfield_10281-1").closest('div.checkbox').hide();
}

AJS.$("#customfield_10280-1").click(function(){
if( AJS.$("#customfield_10280-1").attr('checked') && AJS.$("#customfield_10280-2").attr('checked'))
{ AJS.$("#customfield_10281-1").closest('div.checkbox').show();
}
else
{ AJS.$("#customfield_10281-1").closest('div.checkbox').hide();
}
});

AJS.$("#customfield_10280-2").click(function(){
if( AJS.$("#customfield_10280-1").attr('checked') && AJS.$("#customfield_10280-2").attr('checked'))
{ AJS.$("#customfield_10281-1").closest('div.checkbox').show();
}
else
{ AJS.$("#customfield_10281-1").closest('div.checkbox').hide();
}
});
</script>

However, I can't seem to hide the checkbox field name. Does anybody know the trick for this? Inspecting the element reveals:

<fieldset class="group">
<legend>
<span>CAB Approval</span>
</legend>
<div class="checkbox" style="display: none;">
<input id="customfield_10281-1" class="checkbox" type="checkbox" value="yes" name="customfield_10281">
<label for="customfield_10281-1">yes</label>
</div>
<div class="description">
</fieldset>

5 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

5 votes
Answer accepted
JamieA
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.
July 10, 2011

Something like this should work:

AJS.$(":input[name='" + fieldname + "']").closest('fieldset.group').hide();

Jan Post July 11, 2011

Jamie,

Thnx.

AJS.$(":input[name='customfield_10281']").closest('fieldset.group').hide();

Did it.

Jan

0 votes
Anoop Wilson
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 21, 2012

thanks

0 votes
Jan Post July 11, 2011

Thanks to Jamie, this one is solved!

0 votes
Jan Post July 11, 2011

Hi David,

It's indeed the legend that I'm unable to hide.

Jan

0 votes
David at David Simpson Apps
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
July 10, 2011

When you say"checkbox field name", do you mean the legend, or the label element?

A diagram/picture may also help.

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events