我怎么能得到选择值在django html?



我有一个这样的模态形式。我想根据选中的值在用户面前显示一个不同的表单,但是我无法获得选中的值。我该怎么做呢?

<form>
<div class="modal-body">

<div class="mb-3" id="modal-id" style="display: none;">
<label for="id-field" class="form-label">ID</label>
<input type="text" id="id-field" class="form-control" placeholder="ID" readonly />
</div>



<div class="mb-3">
<select class="form-select" aria-label="Disabled select example" name="typeselect">

<option value="1">Type 1</option>
<option value="2">Type 2</option>
<option value="3">Type 3 </option>
<option value="4">Type 4 </option>



</select>
</div>
{% if typeselect.val == "1" %}
<div class="mb-3 typeforms typeone">
{{typeoneform}}
</div>
{% elif typeselect.val == "2" %}
<div class="mb-3 typeforms typetwo">
{{typetwoform}}
</div>
{% elif typeselect.val == "3" %}
<div class="mb-3 typeforms typethree">
{{typethreeform}}
</div>
{% elif typeselect.val == "4" %}
<div class="mb-3 typeforms typefour">
{{typefourform}}
</div>
{% endif %}
</div>
<div class="modal-footer">
<div class="hstack gap-2 justify-content-end">
<button type="button" class="btn btn-light" data-bs-dismiss="modal">Close</button>
<button type="submit" class="btn btn-success" id="add-btn">Add Customer</button>
<button type="button" class="btn btn-success" id="edit-btn">Update</button>
</div>
</div>
</form>

我想根据我发送到html页面的表单的选项值显示。

  1. 最简单的方法是移动模态div,使其在任何具有特殊定位的元素。一个好地方可能是
  2. 或者,你可以从和它的祖先,直到问题消失。这可能但是,改变页面的外观和功能。

最新更新