473,326 Members | 1,972 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,326 software developers and data experts.

Another Checkbox Question

I am quite new to ASP scripting and seem to be haveing no success with
checkboxes at all.

I have a sql database with bit datatypes and I am trying to create a asp
webform which will display and update the data from checkboxes.

Any help would be appreciated.

Rob
Jul 19 '05 #1
7 1800
What exactly are you having trouble with?

<input type="checkbox"<% If rs.fields.item(0).value = 1 Then response.write
" checked"%>>

Ray at work

"The Corinthian" <g1*********@btconnect.com> wrote in message
news:ck**********@titan.btinternet.com...
I am quite new to ASP scripting and seem to be haveing no success with
checkboxes at all.

I have a sql database with bit datatypes and I am trying to create a asp
webform which will display and update the data from checkboxes.

Any help would be appreciated.

Rob

Jul 19 '05 #2
Rob
Hi,

I am probably mssing some thing I am creating my record set using the
following

data connection provided by inc file
<%
dim rs
dim strSQL


set rs=Server.CreateObject ("ADODB.Recordset")
strSQL = "SELECT ID, Arta, Corinthian, NewsLetter FROM preferences
WHERE ID ='" & _
(Session("userid")) & "'"
Set rs = objConn.Execute (strSQL)

%>

using

<input type="checkbox"<% If rs.fields.Item(Arta).value = 1 Then
response.write" checked"%>>

Returns
Error Type:
ADODB.Fields (0x800A0CC1)
Item cannot be found in the collection corresponding to the requested name
or ordinal.
/dbg12/prefs.asp, line 46

Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
message news:OY*************@TK2MSFTNGP15.phx.gbl...
What exactly are you having trouble with?

<input type="checkbox"<% If rs.fields.item(0).value = 1 Then
response.write " checked"%>>

Ray at work

"The Corinthian" <g1*********@btconnect.com> wrote in message
news:ck**********@titan.btinternet.com...
I am quite new to ASP scripting and seem to be haveing no success with
checkboxes at all.

I have a sql database with bit datatypes and I am trying to create a asp
webform which will display and update the data from checkboxes.

Any help would be appreciated.

Rob


Jul 19 '05 #3
You've got it down just fine with just one small part. You forgot to put
"Arta" in quotes.

rs.Fields.Item("Arta").Value
''or alternatively
rs.Fields.Item(1).Value
'''Arta is the second column, so it has an index of 1. Column indexes start
at zero. So, ID has an index of 0, Arta is 1, Corinthian is 2, Newsletter
is 3.

I suggest that you get in the habit of using Option Explicit at the top of
all your VBS-based ASP pages. If you had Option Explicit, the error would
have been "Variable is not defined - Arta" or something along those lines.

Ray at work

"Rob" <an**@robsbiz.com> wrote in message
news:1A**************@newsfe1-gui.ntli.net...
Hi,

I am probably mssing some thing I am creating my record set using the
following set rs=Server.CreateObject ("ADODB.Recordset")
strSQL = "SELECT ID, Arta, Corinthian, NewsLetter FROM preferences
WHERE ID ='" & _
(Session("userid")) & "'"
<input type="checkbox"<% If rs.fields.Item(Arta).value = 1 Then
response.write" checked"%>> Returns
Error Type:
ADODB.Fields (0x800A0CC1)
Item cannot be found in the collection corresponding to the requested name
or ordinal.
/dbg12/prefs.asp, line 46

Jul 19 '05 #4
Rob
Ah sorted - thank you very very much
"Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
message news:e4*************@TK2MSFTNGP10.phx.gbl...
You've got it down just fine with just one small part. You forgot to put
"Arta" in quotes.

rs.Fields.Item("Arta").Value
''or alternatively
rs.Fields.Item(1).Value
'''Arta is the second column, so it has an index of 1. Column indexes
start at zero. So, ID has an index of 0, Arta is 1, Corinthian is 2,
Newsletter is 3.

I suggest that you get in the habit of using Option Explicit at the top of
all your VBS-based ASP pages. If you had Option Explicit, the error would
have been "Variable is not defined - Arta" or something along those lines.

Ray at work

"Rob" <an**@robsbiz.com> wrote in message
news:1A**************@newsfe1-gui.ntli.net...
Hi,

I am probably mssing some thing I am creating my record set using the
following

set rs=Server.CreateObject ("ADODB.Recordset")
strSQL = "SELECT ID, Arta, Corinthian, NewsLetter FROM preferences
WHERE ID ='" & _
(Session("userid")) & "'"
<input type="checkbox"<% If rs.fields.Item(Arta).value = 1 Then
response.write" checked"%>>

Returns
Error Type:
ADODB.Fields (0x800A0CC1)
Item cannot be found in the collection corresponding to the requested
name or ordinal.
/dbg12/prefs.asp, line 46


Jul 19 '05 #5
I was a bit hasty there - the returning the values is fine now, but now I am
trying to update them.

using

strSQL = "UPDATE preferences SET"
strSQL = strSQL & "Arta Request.Form("Arta") & "'"
strSQL = strSQL & " WHERE ID = Session("UserID")"

but off course the value "ON" wont go into the bit field, how would I
convert it so it compatitble.

Many thanks again.

Rob
"Rob" <an**@robsbiz.com> wrote in message
news:yZ****************@newsfe5-gui.ntli.net...
Ah sorted - thank you very very much
"Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
message news:e4*************@TK2MSFTNGP10.phx.gbl...
You've got it down just fine with just one small part. You forgot to put
"Arta" in quotes.

rs.Fields.Item("Arta").Value
''or alternatively
rs.Fields.Item(1).Value
'''Arta is the second column, so it has an index of 1. Column indexes
start at zero. So, ID has an index of 0, Arta is 1, Corinthian is 2,
Newsletter is 3.

I suggest that you get in the habit of using Option Explicit at the top
of all your VBS-based ASP pages. If you had Option Explicit, the error
would have been "Variable is not defined - Arta" or something along those
lines.

Ray at work

"Rob" <an**@robsbiz.com> wrote in message
news:1A**************@newsfe1-gui.ntli.net...
Hi,

I am probably mssing some thing I am creating my record set using the
following

set rs=Server.CreateObject ("ADODB.Recordset")
strSQL = "SELECT ID, Arta, Corinthian, NewsLetter FROM preferences
WHERE ID ='" & _
(Session("userid")) & "'"
<input type="checkbox"<% If rs.fields.Item(Arta).value = 1 Then
response.write" checked"%>>

Returns
Error Type:
ADODB.Fields (0x800A0CC1)
Item cannot be found in the collection corresponding to the requested
name or ordinal.
/dbg12/prefs.asp, line 46



Jul 19 '05 #6
Give the checkbox a value of 1. Also, you have code enclosed in quotes
below.

<input name="chkArta" type="checkbox" value="1"<% If
CBool(rs.Fields.Item(1).Value) Then Response.Write " checked"%>>

And then in code:

<%
Dim iArta
iArta = Abs(CBool(Request.Form("chkArta")))
strSQL = "UPDATE preferences SET YourColumnNameHere = " & iArta & " WHERE
[ID] = " & Session("UserID")
RESPONSE.WRITE STRSQL
RESPONSE.END
%>

Ray at work

"The Corinthian" <g1*********@btconnect.com> wrote in message
news:ck**********@sparta.btinternet.com...
I was a bit hasty there - the returning the values is fine now, but now I
am trying to update them.

using

strSQL = "UPDATE preferences SET"
strSQL = strSQL & "Arta Request.Form("Arta") & "'"
strSQL = strSQL & " WHERE ID = Session("UserID")"

but off course the value "ON" wont go into the bit field, how would I
convert it so it compatitble.

Jul 19 '05 #7
Rob
Many thanks yet again, I was nearly there, but didn't set a value nor did I
know about CBool.

Cheers again.

Rob

"Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
message news:%2***************@TK2MSFTNGP12.phx.gbl...
Give the checkbox a value of 1. Also, you have code enclosed in quotes
below.

<input name="chkArta" type="checkbox" value="1"<% If
CBool(rs.Fields.Item(1).Value) Then Response.Write " checked"%>>

And then in code:

<%
Dim iArta
iArta = Abs(CBool(Request.Form("chkArta")))
strSQL = "UPDATE preferences SET YourColumnNameHere = " & iArta & " WHERE
[ID] = " & Session("UserID")
RESPONSE.WRITE STRSQL
RESPONSE.END
%>

Ray at work

"The Corinthian" <g1*********@btconnect.com> wrote in message
news:ck**********@sparta.btinternet.com...
I was a bit hasty there - the returning the values is fine now, but now I
am trying to update them.

using

strSQL = "UPDATE preferences SET"
strSQL = strSQL & "Arta Request.Form("Arta") & "'"
strSQL = strSQL & " WHERE ID = Session("UserID")"

but off course the value "ON" wont go into the bit field, how would
I convert it so it compatitble.


Jul 19 '05 #8

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

Similar topics

4
by: Jay | last post by:
Hi everybody ! I am currently writing a webpage that displays a list of records ( each record has a checkbox associated with it) to allow users to select any record they want to delete (much...
0
by: claudel | last post by:
Hi I have a newb PHP/Javascript question regarding checkbox processing I'm not sure which area it falls into so I crossposted to comp.lang.php and comp.lang.javascript. I'm trying to...
2
by: Fred | last post by:
Hi, I defined a form consisting of checkboxes like: <form> <input type="checkbox" name=ck id=ck onclick="check(this.form)" <input type="checkbox" name=ck id=ck onclick="check(this.form)" ........
3
by: Jack | last post by:
<i><input type="checkbox" name="chk_Complete" value="TRUE" <%Response.Write l_IsChecked%>"<%if cbool(l_IsChecked) then Response.Write " checked" Else Response.Write " unchecked"%>> The above...
0
by: Patrick Olurotimi Ige | last post by:
I want to insert checkbox Y/N or 1/0 into a SQL table. I know i can do that using a bit field or Char field. My Question is i have Datalist that lists products and i want to put this checkBoxes...
34
by: clinttoris | last post by:
Hello Experts, I have been told to post this in the Javascript forum as I want to do this client side just before my form gets submitted. Once the user clicks the submit button a javascript...
3
by: delram | last post by:
I'm trying to get user selections (using checkboxes) on one JSP page(A.jsp) and pass them on to another page. So I have one page with a list of dynamically populated items like this 1 2 ...
3
by: chiku1523 | last post by:
Hi, Please find the following code. In function setAnswers, I am looping with each question. I have inner loop, which is looping for each answers of the questions. If any of the answer for question...
1
Death Slaught
by: Death Slaught | last post by:
I play a game that when your backpack fills with items (the limit is 45) you must choose items to discard by unchecking their box. This is very annoying and time consuming so I was wondering if it...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.