Hi Jira-experts,
I have a request to generate a new issue type where the issue screen shows different set of custom fields after selecting an option via a drop-dow-selection-box.
In other words:
- Type-selection-box with n entries.
- Depending on the selection an option (1...n) a different set of custom fields shall be shown.
I would not like to have n separate issue types as some fields are common an only some custom fields depend on the selection.
What would be the (easiest) way to implement this feature?
Thanks for any link, suggestion, idea,..!
BR, Markus
The value won't be "New Account", because since 4.3 select lists are keyed on an ID. ReqType.value will give you the ID... You need to look at the value.
It's easier if you use jquery: AJS.$("#customfield_10032 :selected").text()
Having said that, stuff like this is why I wrote the behaviours plugin... very similar example here.
Thanks Jamie,
will look gain into behaviours plugin.
Seems that I'm stcuk even with basics to get ANY javascript running. Curently not even a "alert('True');" generates any reaction.
Could I have disabled AJS? Where? What is the most simple "Hello World"?
1st I need to get scripting running, then I'll check the functionality.
BR, Markus
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
An alert has to work - where are you putting it, in the field description? Can you check the page source to make sure that JS is actually making it to the page?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Jamie,
I've added a most simple javascript into the 'Description of a custom field in a 'Field Configuration' which is linked to a 'Field Configuration Scheme' which itself is attached to the project where I want to get the javascript running.
This is my great script:
<script type="text/javascript"> alert(True); </script>
I see this code in my browser:
<div class="field-group" > <label for="customfield_10571">Account Type</label> <select class="select" name="customfield_10571" id="customfield_10571"> <option value="-1">None</option> <option value="A">A</option> <option value="B">B</option> </select> <div class="description"><script type="text/javascript"> alert(True); </script></div> </div>
==> Code is in the webpage, but no alert popping up..
I'm really confused as I know some javascript worked half a year ago.
Any other idea?
BR, Markus
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hrm, in the example before you had quotes around the True. Try getting chrome, press F12, and paste that in. I get:
> alert(True);
> ReferenceError
There's no such variable as True.
> Code is in the webpage, but no alert popping up..
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
See this question about using javascript in screens to get the selected value, and this one about showing/hiding fields.
So get the selected value then show/hide the relevant fields.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry for late rection...been busy with other stuff.
I've checked the links and found quite some posts in old forum...but still could not get it running.
Added the javascript to the 'Description' box of the field in "Field Configuration" list. Right? or in Description of "Customu fields" list.
<script type="text/javascript"> var ReqType = document.getElementById('customfield_10570'); ReqType.onchange = function() { var field1 = AJS.$("customfield_10571").closest('div.field-group'); if( ReqType.value == 'New Account' ) { AJS.$("#customfield_10571").closest('div.field-group').show(); } else { AJS.$("#customfield_10571").closest('div.field-group').hide(); } </script>
* Fields 10570 and 10571 are "Select List" fields.
* 10571 has 2 options: "New Account" and "IT Change"
* Intended reaction:
** 10571 = "New Account" => Show 10571
** 10571 = "IT Change" => Hide 10571
* ..but nothing changes on any selection.
Likely it's this type of tiny bug..could anybody guess where it is?
THANKS, Markus
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Nowbody any idea? Help...please ;-)
BR, Markus
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.