<script>
function compare(profile_id)
{
{% ifequal '{{profile.id}}' %}
selected_sub='selected';
{% endife开发者_开发知识库qual %}
}
</script>
How to compare {{profile.id}}
and javascript variable profile_id
function compare(profile_id){
if (profile_id == {{ profilegroup.subject.id }})
\\ do something
}
Keep in mind, that the script must be in a template, not in some served statically file with scripts (it must be filled with values, to work). Remember also, that you simply have templated script, that gets filled, when the response is generated and it will have exactly one value (for the profilegroup passed to the template).
精彩评论