Hi again,

Some progress here, but a minor problem remaining.
On selecting a foo, the page is re-rendered with the correct data
related to the selected foo.

However, the selection list (dropdown) always shows the name of the
first foo, instead of showing the name of the selected foo.
And I need it to display the name of the selected foo, after
selection.

Any help will be appreciated.

At the moment, the code looks like it:

----------------------->foo_relatory.html

<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" name="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;
}

</script>

-------------------------------->views.py

def foo_relatory(request):
.
.
.
.
selected_foo = Foo.objects.get(id=1)

if request.method == 'POST':
    id_selected_foo = request.POST['foos_combo']
    selected_foo = Foo.objects.get(id=id_selected_foo)
.
.
.
.

return render_to_response('foo_relatory.html',
                          {'title'       : title,
                           'show_filter_foos': True,
                          },
                          context_instance=RequestContext(request))

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