我有一个文本提交框,一个“类别”下拉列表,然后是三个“运动”下拉列表(每个运动下拉列表都包含一个分类运动列表。我想用一个输入按钮提交所有三种表单(只提交一项运动下拉已被选中)。使用此代码,文本和内容表单可以像类别一样提交,但运动选择器不起作用,它始终具有“sea”的后元素,这是第一组。我的 if elif 语句有什么问题??
<form method="post">
<div class="row">
<div class="span6">
<h4>post something!</h4>
<label>
<input type="text" placeholder="Subject" name="subject" value="{{subject}}">
</label>
<label>
<textarea style="height: 100px; width: 540px;" name="content">{{content}}</textarea>
</label>
{% if error %}
<div class="alert alert-error">Error: {{error}}</div>
{% endif %}
</div>
<div class="span2">
<h4>categories</h4>
<select name="postcategory">
<option>choose a category</option>
<option>general</option>
<option>discussion</option>
<option>adventures</option>
<option>review</option>
<option>badge applications</option>
</select>
</div>
<div class="span2 offset1">
<h4>choose element and/or sport</h4>
<select name="postsport">
<option value="general sea">--general sea--</option>
<option value="sailing">sailing</option>
<option value="diving">diving</option>
<option value="sailing">surfing</option>
<option value="kite boarding">kite boarding</option>
<option value="kayaking">kayaking</option>
<option value="general air">--general air--</option>
<option value="skydiving">skydiving</option>
<option value="paragliding">paragliding</option>
<option value="hang gliding">hang gliding</option>
<option value="base jumping">base jumping</option>
<option value="balloons">balloons</option>
<option value="general land">--general land--</option>
<option value="rock climbing">rock climbing</option>
<option value="hiking">hiking</option>
<option value="biking">biking</option>
<option value="skiing">skiing</option>
<option value="snowboarding">snowboarding</option>
</select>
</div>
</div>
<input class="btn" type="submit">
</form>
这是我处理这些信息的python postcategory = self.request.get('postcategory') postsport = self.request.get('postsport') postelement = "general"
if postcategory == "choose a category":
postcategory = "general"
if postsport == "sailing" or "diving" or "surfing" or "kite boarding" or "kayaking" or "general sea":
postelement ="sea"
elif postsport == "skydiving" or "paragliding" or "hang gliding" or "base jumping" or "balloons" or "general air":
postelement ="air"
elif postsport == "rock climbing" or "hiking" or "biking" or "skiing" or "snowboarding" or "general land":
postelement ="land"
else:
postelement="general"
postsport = "general"