0
我有一個不同分辨率的大腦模型,我想讓用戶通過從選擇標籤中選擇他想要的分辨率來更改模型的分辨率。使用javascript變量與Django模板
我的意思是我已經加載完整的模型,並沒有發送POST到服務器我想改變大腦模型的視圖。
問題是我無法將選擇的讀取值傳遞給我的django標記以選擇合適的moedl來呈現。
這是我的代碼:
<body>
<select id="resolution_options" onchange="change_brain_resolution()" name="resolution_options">
{% for brain in brains %}
<option value="{{ brain.resolution }}">
{{ brain.resolution_title }}
</option>
{% endfor %}
</select>
<script>
function change_brain_resolution() {
var selcted_resolution = getElementById('resolution_options').value;
{% for brain in brains %}
// Here is my problem !!
{% if brain.resolution == selcted_resolution %}
// Do drawing
{% endfor %}
}
</script>
</body>
爲什麼我不想做一個POST是因爲有很多其他的事情,用戶已經繪製和做,他可能要改變的振振有辭分辨大腦模型以獲得更好的視野或表現,但他想讓其他物體保持在場景中
非常感謝。
你想要的是AJAX,請查看這篇文章:http://stackoverflow.com/questions/20306981/how-do-i-integrate-ajax-with-django-applications –