如何查看组合值和设定值?
我正在尝试将网络上找到的 i18n 示例重写为另一个组件。具有组合的确切链接。
在网络中找到的一个示例看起来
示例是:
<span style="float: right">
<a href="?lang=en">en</a>
|
<a href="?lang=de">de</a>
</span
我的代码
<from action="" method="get">
<select name="lang" id="lang" onchange="this.form.submit();">
<option value="de">DE</option>
<option value ="en">EN</option>
</select>
</form>
我遇到了一个问题。当我更改语言时,i18n 正确启动,但我不知道如何检查参数值的组合 - lang。结果是,如果您更改组合中的值,子组形式将以初始值显示。有谁知道如何解决这个问题?
I'm trying to rewrite an example of i18n found on the network to another component. With the exact link to the combo.
An example found in the network looks
Example is:
<span style="float: right">
<a href="?lang=en">en</a>
|
<a href="?lang=de">de</a>
</span
My code
<from action="" method="get">
<select name="lang" id="lang" onchange="this.form.submit();">
<option value="de">DE</option>
<option value ="en">EN</option>
</select>
</form>
I came across a problem. When I change the language i18n starts correctly, but I do not know how to check the combo of the value of the parameter - lang. The upshot is that if you change the value in the combo and submicie form is presented in the initial value. Does anyone know how to solve this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当值匹配时,将
selected
属性添加到 HTML元素。这是一个基本的启动示例,它根据请求参数执行此操作。
实际上,它可能存储在其他地方,但至少可以归结为,当值匹配时,您应该将
selected
属性添加到 HTML元素。您也可以自己将其存储在会话中,另请参阅这个答案 另一个例子。
Add the
selected
attribute to the HTML<option>
element when the value matches. Here's a basic kickoff example which does that based on the request parameter.In real it might be stored somewhere else, but it at least boils down to that you should add the
selected
attribute to the HTML<option>
element when the value matches. You could also store it in the session yourself, see also this answer for another example.