Can any body Help me to write java script in velocity file?


I coded javascript in velocity file as like as follows , but i am getting errors

please help me to solve this problem

My code:


#[[ $(document).ready(userDetails(){

<table align=center bgcolor="bbbbbb" border="1" cellpadding="0" cellspacing="0" width=100%>

<tr bgcolor="#f0f0f0">

<td valign="center">

<table bgcolor ="#fffff0" border="0" cellpadding="3" cellspacing="1" width="100%" class="grid">

<tr valign="top" bgcolor="#f0f0f0">



#foreach ($element in $action.getAllUsers())

#if($document.form.userNameContains.value == ($element.getName()))

<tr >

<td><input type="checkbox" name="checkbox" align="center">$element.getName()</td>











2 answers

0 vote
Mizan Community Champion Dec 12, 2012

Use AJS.$ instead of $ in your script .

Yes, that , but this still isn't going to work I think. It looks like you're mixing server side and client side contexts. Anything beginning with # is Velocity markup that is converted to 'html' on loading (assuming this is an embedded script), at that time it does not have access to the 'document', so whilst:

#foreach ($element in $action.getAllUsers())

will work fine,

#if($document.form.userNameContains.value == ($element.getName()))

will not, as the 'document' only exists in the client browser. Perhaps you didn't mean it to be Velocity and meant it to just be javascript, if so I think you just need to change the

#if ($document.


if (document.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published yesterday in Jira

5 ways you can make the most of Jira Software and Bitbucket Cloud

As part of the Bitbucket product team I'm always interested in better understanding what kind of impact the use of our tools have on the way you work. In a recent study we conducted of software devel...

35 views 0 4
Read article

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