Q:

how to pass variable in {{ }} to onclick="loadDoc3()" in django

This is a function in my views.py:
def boxes(request):
    v = request.META['PATH_INFO']
    v = v[7:]
    list = v.split('-')
    os = list[0]
    sh = list[1]
    return render(request, 'boxes.html', {'os': os, 'sh': sh})

In boxes.html:
<input type="submit" onclick="loadDoc3( {{ sh }} )" value="other cities">

It does not work. How can I send the {{ sh }} variable with onclick, to the loadDoc3, which is ajax function?

A:

The Javascript will only see the string, so you need to 'quote' sh.
<input type="submit" onclick="loadDoc3( '{{ sh }}' )" value="other cities">

