0

This may be a small issue but I am not getting rid of this . I want to concatenate the argument in a javascript function . This is my string

html+='<a href="javascript:showchart('+data.code+');">';

data.code value is md5 string . But if i do like this it throws the error that fe741b62ff720a180a5960c4a2c50b27 is not defined .

I know it is taking this as constant, but how can I pass this as string within this html .

1 Answer 1

5

You want to pass a string, then you need to wrap variable in quotes, e.g:

html+='<a href="javascript:showchart(\''+data.code+'\');">';

//<a href="javascript:showchart('fe741b62ff720a180a5960c4a2c50b27');">
Sign up to request clarification or add additional context in comments.

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.