Javascript onchange not triggering for SelectList

HI,

I am trying to determine if onchange in Javascript is no longer supported in JIRA (7.2.10).  Below is my logic.  It will not trigger the onchange function.  I want to do something simple and not invest in ScriptRunner right now as this is the only functionality I need currently.  Is there a solution to which someone can direct me? I thought JS would be the simplest way to populate some custom text fields based on the selection in a SelectList component.

 

 

<script type="text/javascript">

var equipLabel = document.getElementById("customfield_11404");

if (equipLabel) {

         equipLabel.onchange=function() {

              alert("in onchange");
              var selectedEquip = this.value;

               //will do something with the value here
       }

}

</script>

1 answer

This widget could not be displayed.

 Nvm... figured it out.

 

How to default fields based on selection of field

Add this to the description field in the field configuration used by the particular project.

<script type="text/javascript">

var equipLabel = document.getElementById("customfield_11404");

if (equipLabel)

{

       equipLabel.onchange=function() {

       var selectedEquip = equipLabel.options[equipLabel.selectedIndex].text;

       var selectedEquipAry = selectedEquip.split(";")

 

       var equipId = selectedEquipAry[0];

       document.getElementById("customfield_11303").value = equipId.trim();;

 

       var equipType = selectedEquipAry[1];

       document.getElementById("customfield_11304").value = equipType.trim();

 

       var equipIMfr = selectedEquipAry[2];

       document.getElementById("customfield_11305").value = equipIMfr.trim();

 

       var equipModelNo = selectedEquipAry[3];

       document.getElementById("customfield_11308").value = equipModelNo.trim();

    }

}

</script>

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

160 views 2 0
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you