Is it possible to show a custom text field based on a value of a custom check box
For example
Check box named "Show"
Text box named "Text"
If the "Show" check box is checked then the "Text" text field would be visible to enter text.
Hi Craig ,
The awesome Behaviours Plugin can be helpful .. there is even a similar sample example here.
How can I use the Behaviours plugin for this -
1) A custom field DL which has values x,y,z,Other as checkboxes.
2) When 'Other' is checked, I want the text area to show up.
Could you please help?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Craig,
For a primer, here's an older page that gives more description about using javascript to update customfields: http://confluence.atlassian.com/display/JIRACOM/Using+JavaScript+to+Set+Custom+Field+Values
Rambanam's code looks to be more succint than mine, if you're going to go the javascrip route and not use Behaviours Plugin. Here is his code, edited to include your customfields. You might have to play with the value of selectedValue, depending on which index No and Yes are at in the Contain field.
<script type="text/javascript"> var selectList = document.getElementById("customfield_10609"); var row = document.getElementById("customfield_10418FieldArea"); row.style.display = 'none'; var selVal = selectList.options[selectList.selectedIndex].value; toggleDuplicateCRs(selVal); selectList.onchange=function(selVal){ toggleDuplicateCRs(selectList.options[selectList.selectedIndex].value); } ; function toggleDuplicateCRs(selectedValue){ if(selectedValue == 1) { row.style.display = ''; }else{ row.style.display = 'none'; } } </script>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Cory;
I have tried the latest code supplied, first in the "Message Custom Field (for edit)" then in the description area of the "Free Text Field (Unlimited Text)" both times nothing happened.
Several Questions:
1. Is there anything in Jira that must be enabled or turned on in order for the JavaScript to function?
2. Is there any way to test that JavaScript will run?
Finally, I tried the Behaviours Plugin which seemed to be functioning until I had to reindex which resulted in a java.lang.NullPointerException error. Don't know how I would would through that because I believe the developer does not offer support.
If you have any ideas, they would be greatly aprreciated.
Thanks
Craig
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hold on, I do nothing *but* offer support! There is currently an issue with "hideable custom field" types but you just want a regular custom field. The hideable ones also hide it from being seen in remote APIs and excel and so on, but if you're considering javascript then you don't need to go there.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Craig,
Unfortunatley, working with javascript is not for the faint of heart. In the browser, it can be very tricky figuring out what's going on. First thing I always check, is to see if there are any errors in the browser console. If using Firefox, you'll want Firebug extension. I use Safari, which has an excellent built-in developer tool. On the page, right-click on the field and Inspect Element, then look at the Consol tab for errors.
Usually, it's a comma, semi-colon or other syntax error, which prevents the javascript from running.
Send me an email at sijitsma at gmail dot com with the exact javascript you have in the field, and I can help debug it for you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jamie:
Sorry if my comment was not correct. How would I go about getting support for plugin?
Sincerely,
Craig T. Hylwa
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
<script type="text/javascript">
var selectList = document.getElementById("resolution");
var row = document.getElementById("customfield_10622FieldArea");
row.style.display = 'none';
var selVal = selectList.options[selectList.selectedIndex].value;
toggleDuplicateCRs(selVal);
selectList.onchange=function(selVal){
toggleDuplicateCRs(selectList.options[selectList.selectedIndex].value);
} ;
function toggleDuplicateCRs(selectedValue){
if(selectedValue == 3){
row.style.display = '';
}else{
row.style.display = 'none';
}
}
</script>
place this script in description of text field
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Craig,
I've done that several times by using javascript. I won't claim by any means to be a great javascript developer, but I can usually hack something together that works.
I typically create a Custom Message customfield, and put all my javascript for the screen in that one field. Here's one example I found, that looks like it would be very similar to what you're looking for:
// Hide/Display entry fields based upon choice in Radio box <script language="javascript"> try { var operTypeField_1 = document.getElementById('operType_1'); var operTypeField_2 = document.getElementById('operType_2'); var operTypeField_3 = document.getElementById('operType_3'); var OperationType = document.getElementById('operTypeFieldArea'); var existingCompFieldArea = document.getElementById('existingCompFieldArea'); var sourceProjectKeyFieldArea = document.getElementById('sourceProjectKeyFieldArea'); var compName = document.getElementById('compNameFieldArea'); var compDescription = document.getElementById('compDescriptionFieldArea'); var compLead = document.getElementById('compLeadFieldArea'); var compAssigneeType = document.getElementById('compAssigneeTypeFieldArea'); // Set default values existingCompFieldArea.style.display = 'none'; sourceProjectKeyFieldArea.style.display = 'none' compName.style.display = ''; compDescription.style.display = ''; compLead.style.display = ''; compAssigneeType.style.display = ''; function checkOperTypeField() { if (operTypeField_2.checked) { existingCompFieldArea.style.display = 'none'; sourceProjectKeyFieldArea.style.display = ''; compName.style.display = 'none'; compDescription.style.display = 'none'; compLead.style.display = 'none'; compAssigneeType.style.display = 'none'; } else if (operTypeField_3.checked) { existingCompFieldArea.style.display = ''; sourceProjectKeyFieldArea.style.display = 'none'; compName.style.display = ''; compDescription.style.display = ''; compLead.style.display = ''; compAssigneeType.style.display = ''; } else { existingCompFieldArea.style.display = 'none'; sourceProjectKeyFieldArea.style.display = 'none' compName.style.display = ''; compDescription.style.display = ''; compLead.style.display = ''; compAssigneeType.style.display = ''; } } OperationType.onclick = checkOperTypeField; } catch(e) { } </script>
-Cory
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Cory:
Thanks for the response. Can you post a screenshot of where you place this Java script?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You'll want to create a customfield of type "Message Custom Field (for edit)", from the JIRA Toolkit Plugin. I name such a customfield "Javascript_Edit".
After creating it, go back and Configure the Javascript_Edit customfield and select Edit Default Value. Paste the Javascript in as the default value. Then place the Javascript_Edit field on your desired Screen, and set any necessary field contexts.
You'll obviously want to edit the javascript to match your actual customfield IDs and names. It looks like my example is referencing the Component fields. For customfields, you'll be referencing 'customfield_10xxx' type IDs.
-Cory
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Cody:
Sorry this is going to be little tedious, my experience in this is slightly more then none. In relation to your comments regarding the component fields vs custom fields. The information related to my custom fields as follows:
Select List:
Field Name=Contain
customFieldId=10609
Options=No, Yes
Free Text Field (Unlimited Text):
Field Name=Contain Action
customFieldId=10418
Can you provide an example of how the code would be modifed to accomodate this information. The basic functionaliy is if a user selects the value "Yes" from the Select List then the Free Text Field "Contain Action" would be visible.
-Craig
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.