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: 

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

Anoop Wilson
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
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

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

0 votes
David at David Simpson Apps
Atlassian Partner
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 Champions.
December 19, 2011

thanks david

TAGS
AUG Leaders

Atlassian Community Events