0

所以我在谷歌应用引擎模板中有这段代码:

<select name='voter'>

{% for voter in allowed_voters %}

    <option {% ifequal voter last_voter %}selected="yes" {% endifequal %} 
    value='{{voter}}'>{{voter}}</option>

{% endfor %}

</select>

该页面不会在选择正确的人的情况下呈现,而是默认为第一个选项。查看源代码显示生成的 html 已将 selected 属性放在正确的位置,所以我无法弄清楚为什么这不起作用。

4

3 回答 3

4

optionselect属性是一个布尔属性。

尝试以下方法之一:

<option {% ifequal voter last_voter %}selected="selected" {% endifequal %} 
value='{{voter}}'>{{voter}}</option>


<option {% ifequal voter last_voter %}selected {% endifequal %} 
value='{{voter}}'>{{voter}}</option>
于 2009-01-22T01:31:35.347 回答
1

布尔属性的语法在 HTML 和 XHTML 中是不同的。显然你正在输出 HTML,需要使用

<option ... selected ...>

在 XHTML 中你会使用

<option ... selected="selected" ...>

不幸的是,我们有整个 HTML/XHTML 和 MIME 类型与可怕的不符合标准的浏览器混在一起。你只需要知道这些东西,以确保你吐出的页面可以在大多数浏览器上正确呈现。

于 2009-02-10T08:47:22.483 回答
0

尝试仅使用标记“已选择”而不是已选择 =“是”

于 2009-01-22T00:54:01.583 回答