开发者

Getting "on" from input in IE

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)
        );


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:

$('<input type="radio" />')
    .attr("id", lista[i].codigo+"RadioVariavel")
    .attr("name", "consulta.variavel")
    .attr("value", lista[i].codigo);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜