Reputation: 391
1.This is the html code where I am calling changeButton which is javascript function.
<a href="#" class="btn btn-primary btn-sm" href="#" onclick="changeButton( "{{ request.session.variable }}" );return false;">Button</a>
2. This is the javascript function which I am calling.
function changeBookNowButton(variable) {
document.getElementById("bookButton").innerHTML=variable
}
3. value of the argument ::request.session.variable is : joe
I am getting error: 1. SyntaxError: syntax error if I pass argument in double quotes "{{ request.session.variable }}" 2. and If without qoutes {{ request.session.variable }} ReferenceError: joe is not defined
Upvotes: 0
Views: 1670
Reputation: 6525
Try this,
<a href="#" class="btn btn-primary btn-sm" href="#" onclick="changeButton( '{{ request.session.variable }}' );return false;">Button</a>
'{{ request.session.variable }}'
Upvotes: 1