473,795 Members | 2,863 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 4603
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
1826
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
4516
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
5881
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
7243
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
9673
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
9522
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10443
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...
1
10165
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
9044
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6783
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
5437
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
5565
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2921
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.