How to get the selected value from Database Values Selection Field using Javascript?

Arunachalam Muthukumar October 22, 2013

Hi,

I have Database Values Selection Field in Create Issue Form. The values from the database are loaded properly in the control. I want to get the selected value from this custom field (when onchange event) and assign it to Summary Field .

I have tried the following javascript with SelectList field.

<script type="text/javascript">

prior = document.getElementById('customfield_10903');

if (prior)

{

prior.onchange=function() {

sum = document.getElementById('summary');

sum.value=prior.options[prior.selectedIndex].text;

}

}

The above code is properly working for SelectList field. I tried this approach for Database Selection Field. But it is not working. Do I need to use something different to get value from Database Selection Field?. Please Advice.

Thanks,

Arunachalam M.

2 answers

1 accepted

0 votes
Answer accepted
RambanamP
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.
October 22, 2013

you can try with this script if your jira version is 5.x and later

&lt;script type="text/javascript"&gt;
jQuery(document).ready(function($) {	
JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e, context) {	
	addSummary();
});
addSummary();
function addSummary(){			
		$('#customfield_10903').change(function() {	
			$('#summary').val($("#customfield_10903 option:selected").text());
		});
}
	
});
&lt;/script&gt;

Arunachalam Muthukumar October 23, 2013

Thanks for your reply. I am using Jira 5.2 only. But this code is not working.

I have added some alert message after this line to test

JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e, context) {

alert('welcome');

It does not show the alert window. Please advice.


RambanamP
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.
October 23, 2013

if youare trying to test it on create screen then check this

https://answers.atlassian.com/questions/47843/strange-javascript-problem-in-create-screen

0 votes
Bharadwaj Jannu
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.
October 23, 2013

you load script as web-resource module and try.

Suggest an answer

Log in or Sign up to answer