复选框设置为OFF不在Request.Form中

编程入门 行业动态 更新时间:2024-10-25 11:33:47
本文介绍了复选框设置为OFF不在Request.Form中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在表单上使用复选框时,如果取消选中它们,则Request.Form集合中未经检查的 名称/值对不会显示。当复选框设置为ON时,只显示。 这是正确的吗?如果是的话,解决方法是什么?

解决方案

" Dan" < TR ***** @ gte>在消息中写道 新闻:Os ************** @ tk2msftngp13.phx.gbl ...

使用复选框时表单,如果取消选中它们,Request.Form集合中未经检查的名称/值对不会显示。只有当复选框设置为ON时才会显示。 这是正确的吗? 是的。 如果有的解决方法是什么?

这取决于什么你想做的。你想做什么? Ray在工作

>这是正确的吗? 是的。

如果有的解决方法是什么?

嗯,这取决于。如果你试图将状态存储在数据库中,而不是试图找出WEREN''T检查的复选框,那么我是否清除了 数据然后重新开始只有选中的选项。这个 逻辑更容易,适用于生成的复选框 动态... 其他你可以做的事情执行: <输入类型=隐藏名称=可能值=''a,b,c''> < input type =复选框name = actual value =''a''> A < input type = checkbox name = actual value =''b''> B < input type = checkbox name = actual value =''c''> C 然后在接收页面上,您可以比较字符串。如果它们不同, 您可以使用拆分来确定哪些元素仍然可能 实际上不是(之前已检查但不再检查)。 /> A

>然后在接收页面上,您可以比较字符串。如果它们不同,

您可以使用拆分来确定哪些元素仍然可能不是实际的(之前已检查但不再检查)。

哦,您还可以确定以前未选中哪些,现在检查 ,例如 < input type = hidden name = possible value =''a,b,c''> < input type = hidden name = previous value =''a,b''> < input type = checkbox name = actual value =''a''CHECKED> A <输入类型=复选框名称=实际值=''b''CHECKED> B < input type = checkbox name = actual value =''c''> C 现在,你可以比较实际到可能(确定那些是未经检查的)你还可以比较实际与之前的比较(以确定两者 之前已经检查过并且已经关闭的那些,以及那些之前未经检查且已经开启的那些。

When using checkboxes on a form, if you uncheck them, the unchecked name/value pair in the Request.Form collection doesn''t show up. It only shows when the checkbox is set to ON. Is this correct? What''s the workaround if it is?

解决方案

"Dan" <tr*****@gte> wrote in message news:Os**************@tk2msftngp13.phx.gbl...

When using checkboxes on a form, if you uncheck them, the unchecked name/value pair in the Request.Form collection doesn''t show up. It only shows when the checkbox is set to ON. Is this correct? Yes it is. What''s the workaround if it is?

That depends on what you''re trying to do. What are you trying to do? Ray at work

> Is this correct? Yep.

What''s the workaround if it is?

Well, that depends. If you are trying to store state in a database, rather than trying to figure out what checkboxes WEREN''T checked, is I clear the data and then start fresh with only the options that were checked. This logic is much easier, and works well with checkboxes that are generated dynamically... Other things you can do: <input type=hidden name=possible value=''a, b, c''> <input type=checkbox name=actual value=''a''> A <input type=checkbox name=actual value=''b''> B <input type=checkbox name=actual value=''c''> C Then on the receiving page, you can compare the strings. If they differ, you can use split to determine which elements are still in possible that aren''t in actual (previously checked but no longer checked). A

> Then on the receiving page, you can compare the strings. If they differ,

you can use split to determine which elements are still in possible that aren''t in actual (previously checked but no longer checked).

Oh and you can also determine which ones were previously unchecked and now are checked, e.g. <input type=hidden name=possible value=''a, b, c''> <input type=hidden name=previous value=''a, b''> <input type=checkbox name=actual value=''a'' CHECKED> A <input type=checkbox name=actual value=''b'' CHECKED> B <input type=checkbox name=actual value=''c''> C Now, you can compare actual to possible (to determine those that are unchecked) and you can also compare actual to previous (to determine both those that were previously checked and have been turned off, and those that were previously unchecked and have been turned on).

更多推荐

复选框设置为OFF不在Request.Form中

本文发布于:2023-10-22 08:33:42,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1516994.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:设置为   复选框   Form   Request

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!