How can I get the value of assignee using AJS.$

Anoop Wilson November 6, 2011

Hi All,

Presently I am Using JAVA scripts for getting value of assignee.My objective is to change the assignee based ona field value.

See the present code I am using for that.I wan to convert this using Jquery.

script type="text/javascript">


assignee = document.getElementById('assignee');
source = document.getElementById('customfield_11290');
sourceFieldArea = document.getElementById('customfield_11290').parentNode;
assigneeFieldArea=document.getElementById('assignee').parentNode;
sourceFieldArea.style.display = 'none';
assigneeFieldArea.style.display = 'none';

if (source.value=="value")
{

assignee.value="user1";

}
else
{

assignee.value="user2";
}


</script>

1 answer

0 votes
David at David Simpson Apps
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
November 6, 2011

Converting your JavaScript to jQuery, you get something like this:

AJS.toInit(function(){
	$assignee = AJS.$('#assignee');
	$source = AJS.$('#customfield_11290');
	$source.parent().hide();
	$assignee.parent().hide();

	if ($source.val()=='value'){ 
		$assignee.children('option[value="user1"]').attr('selected', 'selected');
} else { $assignee.children('option[value="user2"]').attr('selected', 'selected');
} });

...but there's nothing wrong with pure JavaScript :)

Anoop Wilson
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.
December 19, 2011

thanks david

Suggest an answer

Log in or Sign up to answer