Hi,

I am trying to check the check boxes while serve of a page.

I will be passing the elements/indexes of an element(checkbox) as a
list from FORM.

Here is the sample code that I am trying to implement

sampleForm():
  check = [1,3,5]
  hobbies_list = {'1':'Chess', '2':'Cricket', '3':'Tennis',
'4':'Shuttle', '5':'BasketBall'}
  return render_to_response(template.html, {'hoby_list': hobbies_list,
'check_list':check})

template.html
{% for hbyId, hbyVal in hoby_list.items %}
  {% if hbyId in check_list %} ################### - Here I would like
to check the existence of an element
    <input type=checkbox value={{ hbyId }} name="hobby" {{ checkVal }}
> {{ hbyVal }}
  {% else %}
    <input type=checkbox value={{ hbyId }} name="hobby" {{ checkVal }}
> {{ hbyVal }}
  {% endif %}
{% endfor %}

Thanks for your time.

Regards,
Lokesh
--~--~---------~--~----~------------~-------~--~----~
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