Hi.

First, the code in the forms.py:

class TestForm(forms.Form):
    name = forms.CharField( max_length=30 )

Then, the variable is defined in the views.py:

def Test_page(request):
    form = TestForm()
    show_results = False
    variable = ''
    if request.GET.has_key('name'):
        show_results = True
        query = request.GET['name'].strip()
        variable  = 'custom value'
    variables = RequestContext(request, {
        'form': form,
        'show_results': show_results,
        'variable': variable
         })
    return render_to_response('Test.html', variables)

I know the value of variable can be accessed by using {{variable}} in
the Test.html. However, if I want use the jQuery in the Test.html and
pass the value of this variable to the jQuery function, how to do
that?

I have tried: var x = $("variable").val(), and not succeed.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to