473,405 Members | 2,261 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

value of checked box!?

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
Jul 22 '05 #1
2 4578
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

Jul 22 '05 #2
"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%>>

Jul 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Jerome | last post by:
Hi, I've got the following problem: I'm retrieving data from an SQL Server database (the data itslef was entered by an ASP form). And on an 'edit form' I want to display a checked box in the...
3
by: Julia | last post by:
I have a multi-value drop down box (<select name="Users" multiple>...) When my form is posted, i can read Request.Form.Item("Users"), a string that contains all values separated by comma. The...
2
by: rich | last post by:
I am populating a list box from a dictionary table and then picking muliple values to insert into a detail table. How do I get the list box to have multiple selections highlighted when I pick one...
4
by: sicapitan | last post by:
I have this code snippet: updateProps snippet: if (mycheckbox.checked == '1') ? $('mycheckbox').checked = true : $('mycheckbox').checked = false; content = $('mydiv').innerHTML;
1
by: jamesnkk | last post by:
I create a continue form which show all customer back order. I also have a bound checkbox from the same table. I am trying out the checkbox correctly, For example if the first attempt I checked...
2
by: grahama2 | last post by:
Greetings. I am writing a database with a search feature to go through 1 table and extract relavant records to be displayed on a subform in spreadsheet style. I have 8 txt boxes that can all recieve...
14
by: cobolguy | last post by:
I am trying to add the cr/lf characters to a form text box. I have used both text and a memo field that is set for Rich Text. I can add them to a string, display the string in a message box - but...
2
by: jerald m | last post by:
Hi, how can i pass the user input value of ( in text box field) to the another Jsp in url? Form Code <td> <input type="text" name="dil_ProjectCode" id="dil_ProjectCode"> </td>
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.