Hi
I coded javascript in velocity file as like as follows , but i am getting errors
please help me to solve this problem
My code:
<script>
#[[ $(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">
<td><b>$action.getText("bulkuserdeactivation.name")</b></td>
</tr>
#foreach ($element in $action.getAllUsers())
#if($document.form.userNameContains.value == ($element.getName()))
<tr >
<td><input type="checkbox" name="checkbox" align="center">$element.getName()</td>
</tr>
#end
#end
</table>
</td>
</tr>
</table>
});
]]#
</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.
for
if (document.
Use AJS.$ instead of $ in your script .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.