473,785 Members | 2,457 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Field s.Item("lien"). Value = 1 Then Response.Write( "
checked='checke d'") : Response.Write( "")%>>

and like this:

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

But neither works. The checkbox remains unchecked!?

What am I doing wrong?

Thanks a lot,

Jerome
Jul 22 '05 #1
2 4602
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******** ******@tk2msftn gp13.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.Field s.Item("lien"). Value = 1 Then Response.Write( "
checked='checke d'") : Response.Write( "")%>>

and like this:

<input name="checkbox" type="checkbox" value="checkbox " <%If
cstr(rsDemande. Fields.Item("li en").Value) = "True" Then Response.Write( "
checked='checke d'") : 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******** ******@tk2msftn gp13.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.Field s.Item("lien"). Value = 1 Then Response.Write( "
checked='checke d'") : Response.Write( "")%>>

and like this:

<input name="checkbox" type="checkbox" value="checkbox " <%If
cstr(rsDemande. Fields.Item("li en").Value) = "True" Then Response.Write( "
checked='checke d'") : 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='checke d'>

Change your code to:

<%
Dim strCHK
If CStr(rsDemande. Fields.Item("li en").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
576
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 state corresponding to the value saved in the DB. But somehow that doesn't work!? SQL tells me the value is 1.
3
1527
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 problem is, that each value itself can contain comma as well, in which case i have no way to separate my values. For example, my list box contains Smith, John and Cohen, David, two values. When the selection box is posted, i am getting "Smith, John,...
2
1825
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 of the master items?
4
4515
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
1328
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 rows and click the Submit button, it show me the 2 records checked correctly with the back order qty correctly. On the 2nd attempt, if I removed one checkbox and remain the other checked and click the button again, it show nothing been...
2
2239
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 data and search through the table with the search terms AND'd or OR'd together. The table has fields that are the same as the search text boxes ( 'Proj' txtBox --> 'Proj' in the table.) My problem is that I would like to be able to put multiple...
14
5880
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 when I move the string to the forms field the CR/LF are being stripped out. I do not know how to overcome that. Here is a snippet of code: Private Sub ParentParcel_DblClick(Cancel As Integer) 'On Error GoTo EndSub ' '''''' ' ' '''''' Dim...
2
7242
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
9645
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10325
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10091
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9950
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6739
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5381
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4050
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.