Question

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

Was it helpful?

Solution

Try this,

<a href="#" class="btn btn-primary btn-sm" href="#" onclick="changeButton( '{{ request.session.variable }}' );return false;">Button</a>

'{{ request.session.variable }}'

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top