[問題] Django select event

作者: gbllggi (gbllggi)   2015-05-05 06:26:35
大家好, 我正在用django練習寫個小網站
但碰到了一個問題,找不到範例可以參考
我希望網頁能顯示如下:
選擇: A下拉選單 B下拉選單
建議: C
能不能讓C的顯示內容依照A、B下拉選單而不同呢?
假設A選1 B選2 > C顯示ex1
A選2 B選2 > C顯示ex2
我的html長這樣:
<table>
<tr>
<td>Type: </td>
<td align="center">
<select name="DV_type">
{% for type in variable_type %}
<option name="DV_type" value={{ type }}>{{ type }}</option>
{% endfor %}
</select>
</td>
<td align="center">
<select name="IV_type">
{% for type in variable_type %}
<option name="IV_type" value={{ type }}>{{ type }}</option>
{% endfor %}
</select>
</td>
</tr>
<tr>
<td>Suggestion: </td>
<td colspan="2" align="center"> {{ model_suggestion }}</td>
</tr>
</table>
總之我希望網頁顯示的內容依使用者的選擇而變化,但停留在同一頁
有辦法在django裡做到嗎?
謝謝!!
作者: dritchie (卍~邁斯納效應~卍)   2015-05-05 08:14:00
AJAX 是一種方式
作者: phate334 (阿賢)   2015-05-06 14:30:00
資料不多的話也可以全送到前端做
作者: frank910138 (frank)   2015-05-06 17:01:00
要用到js

Links booklink

Contact Us: admin [ a t ] ucptt.com