Monday, December 31, 2018

How to get selection from 2nd dropdown list from template

{% extends 'base.html' %} {% block javascript %} {% endblock %} {% block content %}

Lock Operations Report

{% endblock %} {% for lock in locks %} {% endfor %}
Hello,

I am a newbie to Django.  I am trying to build a page with dependent dropdown lists.  The second list is populated based on the 1st list selection.  I am using one html template for both dropdowns with select ids.   I used the .change jquery script to grab the first dropdown selection with .ajax call to populate the second list via python script to my database.  This works but I don't know how to trigger the select from the 2nd dropdown.  Currently the return from the python script renders a small snippet of html which loads the option list but does not include the select id.  Tried the .change jquery script on the 2nd dropdown select id, but nothing happens.  I suspect that since the html snippet only contains loading the option list that there is no visibility to the select id tag for this dropdown in the original html template.  Also, since there is no id in this snippet I cannot uniquely identify the selection for the jquery function call.

How can I trigger the select on the 2nd dropdown to send the selection back to a python script for processing?

I included my html templates for your reference.  Any help would be appreciated!

Thanks,
Debbie

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/1d6f717a-a9ae-4e90-8e92-113b7c3d0777%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment