Pass array from html to javascript

I have a form which has multiple drop-down boxes. I wish to pass the value in these drop-down boxes as an array to a JavaScript function.

Currently my code is like:


                    {% for film in all_films %}
                        {{film.f_material}}
                    {% endfor %}
                    

Where all_films is a variable from Django framework [Most probably you need not concern yourself with it].

What I want to do is that even if I have multiple selects with different names such as findByMaterial and findByColor, and I change the findByColor, then it should call the filterFilms[String,Value] JS function.

Any pointers in the right direction would be appreciated a lot.

PS: This question is probably similar to how to pass array values to JavaScript function from html onchange action?, but it is definitely not what I am looking for.

CLarification: I wish to create a filter. Thus I would want to be able to access the attribute of color as well as material.

51

Hi guys, what I'm trying to do is very simple. Just make a simple check/uncheck button for some checkboxes. Here's what I have.

  1.  
  2. function checkAll[field]
  3. {
  4.     for [i = 0; i 

Chủ Đề