开发者

html: how to uncheck a checked checkbox

I have an html form with a checked checkbox:

&l开发者_运维知识库t;input type=checkbox name="somebox" value="somevalue" checked />

When I get this form, uncheck the checkbox and post the form again, the checkbox is still being passed on together with submitted data. So, unchecking in does nothing finally.

Is there a way to uncheck it? Or may be there is another way to indicate that the checkbox is checked (without using "checked" keyword)?

Thanks in advance

UDP Finally it was a bug in another place. Checkbox logics is all right. Thanks everyone.


If you have unchecked the checkbox, the "somebox" will not be passed a request parameter.

You must have made a mistake somewhere else.


You could use javascript or jQuery to uncheck it but that's hardley solving the problem.

Sounds like your fighting with viewstate and you'll either need to place this in an update panel, or out side the panel depending on needs, or in your code behind set the checked value of the control before you come back to the page.

get rid of the "checked" property in the control might also be a good start as everytime it comes back from a post it will try to check the box. instead, set it's checked state in the code behind.


If its not checked the name may be passed (often libraries do this when building a request) but the value will not, so if the value of somebox is not somevalue, its not checked.

See How come checkbox state is not always passed along to PHP script?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜