Hello,

I'm a newbie struggling with a simple problem for some time now.
I know it is a simple problem and it is a shame that I don't know how
to solve it.

I have a django spaguetti code that, instead of using forms, uses
javascript functions to get a selection from a selection list
(<select></select>).

Since I have some deadlines, I'm thinking on use request.POST (saw
some
about it on results from google), but I don't know when, where an how
to use
request.POST to get the selection  and work on it on the view.

Basicaly, there are a Foo class on Models.py

And I need to get the selected "foo" object from the dropdown to,
then, list
data relatated to that foo in the same page.

The relevants parts of the code are the following:


---->foo_relatory.html   (template)

<form method="POST" action="" id="filters">
<tr>
<td>
{% if show_foos_filter %}
  <span id="foos" style="text-align: right;">
      Foo:&nbsp;
      <select id="foos_combo" onChange="filter();">
        {% for foo in foos %}
          <option value="{{ foo.id }}">{{ foo.nome }}</option>
        {% endfor %}
      </select>
      <input type="hidden" name="foo" id="input_foo">
  </span>
{% endif %}
</td>
</tr>
</form>

<script>
function filter(){
    var formOK = false;

    {% if show_foos_filter %}
        formOK = CheckFoo();
    {% endif %}

    if (formOK == true) {
        submitForm('filters');
    }
}



function submitForm(formID){
    var f = document.getElementById(formID);
    f.submit();
}


function CheckFoo(){
    combo = document.getElementById('foos_combo');
    document.getElementById("input_foo").value = combo.options
[combo.selectedIndex].value;
    return true;
}

</filter>



---->views.py

def foo_relatory(request):
#
#
# some python code here
#
return render_to_response('foo_relatory.html',
                          {'title'       : title,
                           'show_filter_foos': True,
                          },
                          context_instance=RequestContext(request))


Thanks in advance,

Samuel.

--~--~---------~--~----~------------~-------~--~----~
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