开始“上”从 IE 中输入
这是问题我有一个应用程序可以在除 IE(8) 之外的所有浏览器中运行。 它是一个简单的表单,填充了来自 ajax 请求的数据。底部有一个按钮,用于将数据发送到服务器并获取生成的查询。
问题是,在 IE 中,当用户按下查询按钮时,浏览器将所有复选框或单选按钮值作为字符串“on”发送,尽管 value 属性明显不同于“on”。
为什么会发生这种情况?
我正在使用 java 和 spring mvc(版本 3)。
我没有附加任何代码,因为我什至不确定哪部分代码可能有用。此外,该应用程序大小适中,因此我将根据需要发布代码片段。
[编辑] 使用开发人员工具,我发现该值正在正确传递,但在设置输入后,其值变为“on”。我用 javascript 生成的输入检查了这一点。对于加载的那些,我不知道为什么要这样设置。
下面是 DOM 生成的一个小片段:
var cell = $("<td/>").append(
$("<input/>")
.attr("id", lista[i].codigo+"RadioVariavel")
.attr("name", "consulta.variavel")
.attr("value", lista[i].codigo)
.attr("type", "radio")
).append(
$("<label/>")
.attr("for", lista[i].codigo+"RadioVariavel")
.html(lista[i].descricao)
);
Here is the problem I have an app that is working in every browser but IE(8).
Its a simple form that is filled with data from ajax requests. At the bottom there is a button that sends the data to the server and gets a generated query.
The problem is, at IE when the user presses the query button, the browser sends all checkbox or radiobutton values as the string "on" although the value attribute is clearly different from "on".
Why is that happening?
I am using java and spring mvc(version 3).
I haven't attached any code because I am not even sure what section of code could be useful. Also the application is medium size so, I'm going to post code snippets on demand.
[Edit]
Using developer tools I was able to find that the value is being passed correctly but just after the input is set, its value becomes "on". I checked that with javascript generated inputs. For the ones that are loaded, I do not know why they are set that way.
Here is a small snippet of that DOM generation:
var cell = $("<td/>").append(
$("<input/>")
.attr("id", lista[i].codigo+"RadioVariavel")
.attr("name", "consulta.variavel")
.attr("value", lista[i].codigo)
.attr("type", "radio")
).append(
$("<label/>")
.attr("for", lista[i].codigo+"RadioVariavel")
.html(lista[i].descricao)
);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我以前遇到过类似的问题。我很惊讶您没有收到彻底的错误,因为 jQuery 不允许您更改输入类型。
试试这个:
I've run into a similar problem before. I'm suprised that you are not getting an outright error, because jQuery doesn't allow you to change the input type.
Try this instead: