2

I am passing a parameter to a javascript function from jsp.

  <a href="javascript:void(0)" title="Update" 
   onclick="fnUpdate(<s:property value='roleTypeUid'/>);">

Now the roleTypeUid is a String with space in between (eg. System Admin) . So it is not working . If I replace the attribute with a no-space string , it gets passed fine.

Am I missing something ?

2 Answers 2

1

Try like this:

<a href="javascript:void(0)" 
   title="Update" 
   onclick="fnUpdate('<s:property value='roleTypeUid'/>');">
Sign up to request clarification or add additional context in comments.

4 Comments

I get this error Error: illegal character Source File: localhost:8080/searchRole Line: 1, Column: 9 Source Code: fnUpdate(\
@vinoth You may need to escape them.
@vinoth, how about onclick="fnUpdate('<s:property value='roleTypeUid'/>');"?
Is roleTypeUid meant to be a string or an included variable? Did Darin forget to escape it?
1

The called function within onclick has to be a string, you can't reference variables directly in it.

onclick="fnUpdate(\"<s:property value='roleTypeUid'/>\");"

That string is evalled onclick and thus becomes a function. That's why it may be better to add handlers unobtrusive

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.