The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Javascript onchange not triggering for SelectList

Tammy Robinson
Contributor
September 12, 2017

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

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

0 votes
Tammy Robinson
Contributor
September 14, 2017

 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>

TAGS
AUG Leaders

Atlassian Community Events