复选框的价值!? [英] value of checked box!?

查看:60
本文介绍了复选框的价值!?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我遇到了以下问题:


我正在从SQL Server数据库中检索数据。而且我希望我的表单能够显示一个复选框,其状态对应于保存在数据库中的值b / b
。但不知何故,这不起作用!?


SQL告诉我值为1.

我的ASP页面告诉我它是''真的''??


所以我尝试了这样:

< input name ="复选框"类型= QUOT;复选框"值= QUOT;复选框" <%If

rsDemande.Fields.Item(" lien")。Value = 1 Then Response.Write("

checked =''checked''" ;):Response.Write("")%>>


和这样:


< input name = "复选框"类型= QUOT;复选框"值= QUOT;复选框" <%If

cstr(rsDemande.Fields.Item(" lien")。Value)=" True"然后Response.Write("

checked =''checked''"):Response.Write("")%>>


但不起作用。复选框仍未选中!?


我做错了什么?


非常感谢,


杰罗姆

解决方案

你试过=" 1" ? SQL Server数据库中的数据类型是什么?


仅对asp.db进行后续跟踪。


-
http://www.aspfaq.com/

(反向地址到回复。)


" Jerome" <无**** @ nospam.com>在消息中写道

新闻:e5 ************** @ tk2msftngp13.phx.gbl ...


我遇到了以下问题:

我正在从SQL Server数据库中检索数据。我希望我的表单能够显示一个复选框,其状态与数据库中保存的值相对应。但不知怎的,这不起作用!?

SQL告诉我价值是1.
我的ASP页面告诉我它''真''??

所以我尝试了这样:
< input name =" checkbox"类型= QUOT;复选框"值= QUOT;复选框" <%If
rsDemande.Fields.Item(" lien")。Value = 1 Then Response.Write("
checked =''checked''"):Response.Write(" ;")%>>

并且像这样:

< input name ="复选框"类型= QUOT;复选框"值= QUOT;复选框" <%If
cstr(rsDemande.Fields.Item(" lien")。Value)=" True"然后Response.Write("
checked =''checked''"):Response.Write("")%>>

但是都不起作用。复选框仍未选中!?

我做错了什么?

非常感谢,

杰罗姆



"杰罗姆" <无**** @ nospam.com>在消息中写道

新闻:e5 ************** @ tk2msftngp13.phx.gbl ...


我遇到了以下问题:

我正在从SQL Server数据库中检索数据。我希望我的表单能够显示一个复选框,其状态与数据库中保存的值相对应。但不知怎的,这不起作用!?

SQL告诉我价值是1.
我的ASP页面告诉我它''真''??

所以我尝试了这样:
< input name =" checkbox"类型= QUOT;复选框"值= QUOT;复选框" <%If
rsDemande.Fields.Item(" lien")。Value = 1 Then Response.Write("
checked =''checked''"):Response.Write(" ;")%>>

并且像这样:

< input name ="复选框"类型= QUOT;复选框"值= QUOT;复选框" <%If
cstr(rsDemande.Fields.Item(" lien")。Value)=" True"然后Response.Write("
checked =''checked''"):Response.Write("")%>>

但是都不起作用。复选框仍未选中!?

我做错了什么?

非常感谢,

杰罗姆




当你通过时它应该是这样的:


< input name ="复选框"类型= QUOT;复选框"值= QUOT;复选框"检查>


我的猜测是你的看起来像这样:


< input name ="复选框"类型= QUOT;复选框"值= QUOT;复选框" checked =''checked''>


将您的代码更改为:


<%

Dim strCHK

如果CStr(rsDemande.Fields.Item(" lien))。Value)=" True"然后strCHK ="

check"

%>


< input name =" checkbox"类型= QUOT;复选框" value ="复选框"<%= strCHK%>>


Hi,

I''ve got the following problem:

I''m retrieving data from an SQL Server database. And I want my form to
display a checked box in the state corresponding to the value saved in
the DB. But somehow that doesn''t work!?

SQL tells me the value is 1.
My ASP page tells me it''s ''True''??

So I tried it like this:
<input name="checkbox" type="checkbox" value="checkbox" <%If
rsDemande.Fields.Item("lien").Value = 1 Then Response.Write("
checked=''checked''") : Response.Write("")%>>

and like this:

<input name="checkbox" type="checkbox" value="checkbox" <%If
cstr(rsDemande.Fields.Item("lien").Value) = "True" Then Response.Write("
checked=''checked''") : Response.Write("")%>>

But neither works. The checkbox remains unchecked!?

What am I doing wrong?

Thanks a lot,

Jerome

解决方案

Did you try = "1" ? What is the datatype in the SQL Server database?

Followups to asp.db only.

--
http://www.aspfaq.com/
(Reverse address to reply.)


"Jerome" <no****@nospam.com> wrote in message
news:e5**************@tk2msftngp13.phx.gbl...

Hi,

I''ve got the following problem:

I''m retrieving data from an SQL Server database. And I want my form to
display a checked box in the state corresponding to the value saved in
the DB. But somehow that doesn''t work!?

SQL tells me the value is 1.
My ASP page tells me it''s ''True''??

So I tried it like this:
<input name="checkbox" type="checkbox" value="checkbox" <%If
rsDemande.Fields.Item("lien").Value = 1 Then Response.Write("
checked=''checked''") : Response.Write("")%>>

and like this:

<input name="checkbox" type="checkbox" value="checkbox" <%If
cstr(rsDemande.Fields.Item("lien").Value) = "True" Then Response.Write("
checked=''checked''") : Response.Write("")%>>

But neither works. The checkbox remains unchecked!?

What am I doing wrong?

Thanks a lot,

Jerome



"Jerome" <no****@nospam.com> wrote in message
news:e5**************@tk2msftngp13.phx.gbl...

Hi,

I''ve got the following problem:

I''m retrieving data from an SQL Server database. And I want my form to
display a checked box in the state corresponding to the value saved in
the DB. But somehow that doesn''t work!?

SQL tells me the value is 1.
My ASP page tells me it''s ''True''??

So I tried it like this:
<input name="checkbox" type="checkbox" value="checkbox" <%If
rsDemande.Fields.Item("lien").Value = 1 Then Response.Write("
checked=''checked''") : Response.Write("")%>>

and like this:

<input name="checkbox" type="checkbox" value="checkbox" <%If
cstr(rsDemande.Fields.Item("lien").Value) = "True" Then Response.Write("
checked=''checked''") : Response.Write("")%>>

But neither works. The checkbox remains unchecked!?

What am I doing wrong?

Thanks a lot,

Jerome



When you''re through it should look like this:

<input name="checkbox" type="checkbox" value="checkbox" checked>

My guess is that yours will look like this:

<input name="checkbox" type="checkbox" value="checkbox" checked=''checked''>

Change your code to:

<%
Dim strCHK
If CStr(rsDemande.Fields.Item("lien").Value) = "True" Then strCHK = "
checked"
%>

<input name="checkbox" type="checkbox" value="checkbox"<%=strCHK%>>


这篇关于复选框的价值!?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆