【发布时间】:2016-08-31 22:28:56
【问题描述】:
我的 HTML 中有这个表单:
<form action="/vcontent?topic={{ topic.name }}" method="post">
{% if user and user.email in c.users_up %}
<input type="image" src="icons/thumb-up.png" alt="Up!" name = "vote" value = "up" />
{% else %}
<input type="image" src="icons/thumb-up_gray.png" alt="Up!" name = "vote" value = "up" />
{% endif %}
{% if user and user.email in c.users_down %}
<input type="image" src="icons/thumb-down.png" alt="Down!" name = "vote" value = "down" />
{% else %}
<input type="image" src="icons/thumb-down_gray.png" alt="Down!" name = "vote" value = "down" />
{% endif %}
<input name= "content_key" type="hidden" value="{{ c.key.urlsafe() }}">
</form>
当我尝试在 Chrome 上为内容投票时,它运行良好。当我通过以下方式获得价值时:
vote = self.request.get('vote')
我应该是“向上”或“向下”。
但是当我在 IE 和 Firefox 上做同样的事情时,我得到一个空字符串。
(HTML 中的 if/else 语句表示如果用户尚未对特定内容进行投票,则图标显示为灰色,否则为黑色)。
我正在使用 Jinja2 作为模板引擎开发 Google App Engine。
【问题讨论】:
-
您知道
<input type="image"会提交表单吗? -
是的,它就是这样工作的。这是一个在按下时提交表单的图标。但它应该使用 vote = "up" 或 vote = "down",而不是 vote = ""。
标签: html internet-explorer firefox jinja2