我有两个下拉列表。如果用户只从一个选择框中选择某些内容,我想重新呈现具有相同下拉列表的页面,除了选择的页面显示上一个选择而不是默认选择。
html看起来像
<div>
<select name = "menu" value = "{{menu}}">
<option value = "selected">select something</option>
<option value = "a">a</option>
<option value = "b">b</option>
<option value = "c">c</option>
</select>
</div>
<div>
<select name = "location" value = "{{location}}">
<option value = "selected">select something</option>
<option value = "d">d</option>
<option value = "e">e</option>
<option value = "f">f</option>
</select>
</div>
python 看起来像 menu = self.request.get('menu') location = self.request.get('location')
if menu!="selected" and location!="selected":
d = Delivery(parent = delivery_key(),
menu = menu, location = location)
d.put()
deliverystatus = "success"
self.render('page.html',
deliverystatus = deliverystatus, menu = menu, location = location)
else:
error = "please select something from both lists"
self.render("page.html",
menu = menu, location = location, error = error)
当出现错误并重新呈现页面时,我在两个框中都将“选择某些内容”作为默认值。我该如何改变?