473,795 Members | 2,863 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using Checkbox for assigning items

I have a catalog of books which need to be categorized into different
groups. Some of the books can be listed under more than one category.
I'm creating a page where I can assign a group of books to a category
by checking the checkbox next to their name (say I've looped out 100
of them, and check some, and not others) then submitting the form for
processing, so that those titles where the checkbox is checked will
get the categoryid number assigned to them on a one-to-many table

I need to know how to read the checkbox value as it comes in if it is
selected or not, if it is, I'll send the isbn in one direction, and if
not, I won't send it at all.

So, how would I read this on the sheet that grabs the values?

Thanks,

Bill
Jul 19 '05 #1
4 4671
Request.Form("c hkBoxName")

Is that what you mean?

--
----------------------------------------------------------
Curt Christianson (Software_AT_Da rkfalz.Com)
Owner/Lead Designer, DF-Software
http://www.Darkfalz.com
---------------------------------------------------------
...Offering free scripts & code snippits for everyone...
---------------------------------------------------------
"Bill" <bi***********@ gospellight.com > wrote in message
news:8d******** *************** ***@posting.goo gle.com...
I have a catalog of books which need to be categorized into different
groups. Some of the books can be listed under more than one category.
I'm creating a page where I can assign a group of books to a category
by checking the checkbox next to their name (say I've looped out 100
of them, and check some, and not others) then submitting the form for
processing, so that those titles where the checkbox is checked will
get the categoryid number assigned to them on a one-to-many table

I need to know how to read the checkbox value as it comes in if it is
selected or not, if it is, I'll send the isbn in one direction, and if
not, I won't send it at all.

So, how would I read this on the sheet that grabs the values?

Thanks,

Bill

Jul 19 '05 #2
No, that's not what I mean. I know how to get the names off the
submitted form. What I don't understand is how to grab the value of
checked or not checked.

For example,

if checkbox1=check ed then
do this
else
do that
end if

This should work, but the opposite is happening. The above code will
process those that are not checked, and ignore those that are, so I
can't figure out how to assigned the checked value to the name. If it's
checked, do I write checked, or selected, or what?

Thanks,

Bill

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #3
"Bill" <Bi***********@ gospellight.com > wrote in message
news:OR******** ******@TK2MSFTN GP11.phx.gbl...
No, that's not what I mean. I know how to get the names off the
submitted form. What I don't understand is how to grab the value of
checked or not checked.

For example,

if checkbox1=check ed then
do this
else
do that
end if

This should work, but the opposite is happening. The above code will
process those that are not checked, and ignore those that are, so I
can't figure out how to assigned the checked value to the name. If it's checked, do I write checked, or selected, or what?


[CategoryBooksFo rm.asp]
..
..
..
<input type="Hidden" name="CategoryI D" value="222">
<input type="Checkbox" name="BookIDs" value="101">Nam e of book whose ID
is 101<br>
<input type="Checkbox" name="BookIDs" value="102">Nam e of book whose ID
is 102<br>
<input type="Checkbox" name="BookIDs" value="103">Nam e of book whose ID
is 103<br>
<input type="Checkbox" name="BookIDs" value="104">Nam e of book whose ID
is 104<br>
..
..
..
[CategoryBooksIn sert.asp]
..
..
..
sql = _
"INSERT INTO CategoryBook (CategoryID,Boo kID)" & vbCRLF &_
"SELECT " & Request.Form("C ategoryID") & " AS CategoryID, BookID" &
vbCRLF &_
"FROM Book" & vbCRLF &_
"WHERE BookID IN (" & Request.Form("B ookIDs") & ")"
Set cn = CreateObject("A DODB.Connection ")
cn.Open "File Name = C:\SomePathOuts ideAppRoot\MyCo nnection.UDL"
cn.Execute sql,,&H81
..
..
..
Notes:
1. In future posts, please provide database, version and table structure
information as this will often result in a responses crafted to suit
your particular environment.
2. When something is not working as expected, please post code. Just
enough to allow readers/responders to understand your methodology and
reproduce the behavior.
3. When dealing with databases, if a query is not behaving as expected,
Response.Write the SQL statement and cut and paste the generated text
into the Access Query Design Grid/SQL Server Query Analyzer. These query
building environments provide a richer feature set than ASP for
analyzing/debugging SQL statements.
4. The above is obviously not code-complete. Please make sure you
perform due diligence. Close/destroy all objects, validate parameters,
include error handling, etc...
5. Once the above code is working, please consider encapsulating the
insertion logic into a parameterized query/stored procedure. If the
database supports full-fledged stored procedures (SQL Server, Oracle,
MySQL 5.0, etc...) then you should also consider implementing a
set-based solution to passing an array of values into stored procedures.
Here's a link with more information on that topic.

http://www.algonet.se/~sommar/arrays-in-sql.html

HTH
-Chris




Jul 19 '05 #4
I face this issue quite a lot. My solution is to accompany each checkbox
with a hidden control, both similarly named, as in:

<input type="checkbox" name="chkBookNu mber1"> Book Title
<input type="hidden" name="hidBookNu mber1" value="(checked =1, not
checked=0)">

When the form is submitted, I compare the two.
If the hidden control is 1 and the checkbox is "empty": it was selected,
now it's not
If the hidden control is 1 and the checkbox is 1: nothing's changed
If the hidden control is 0 and the checkbox is "empty": it was not
selected, nothing's changed
If the hidden control is 0 and the checkbox is 1: it wasn't selected,
now it is

Takes a bit of processing, but it's worth it.
--
William Morris
Product Development, Seritas LLC
"Bill" <bi***********@ gospellight.com > wrote in message
news:8d******** *************** ***@posting.goo gle.com...
I have a catalog of books which need to be categorized into different
groups. Some of the books can be listed under more than one category.
I'm creating a page where I can assign a group of books to a category
by checking the checkbox next to their name (say I've looped out 100
of them, and check some, and not others) then submitting the form for
processing, so that those titles where the checkbox is checked will
get the categoryid number assigned to them on a one-to-many table

I need to know how to read the checkbox value as it comes in if it is
selected or not, if it is, I'll send the isbn in one direction, and if
not, I won't send it at all.

So, how would I read this on the sheet that grabs the values?

Thanks,

Bill

Jul 19 '05 #5

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

Similar topics

1
4161
by: iforsyth | last post by:
Have a paging datagrid with a checkbox control in column(0). ViewState is enabled. I check the checkbox in first row of the grid on a page and then the program hits this event: Private Sub dgRegGrid_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles dgRegGrid.PageIndexChanged I then do a loop to check the checkbox state.
2
2726
by: Martin | last post by:
Hi, Please can somebody explain how databinding is done on a checkbox list. I have the follwoing code which I would have thought was enough to databind a checkbox, but apparently not. The data is coming from an sql server database "Name" is a text feild "Valid" is a bit field
1
3781
by: VB Programmer | last post by:
Simple: I have a datalist that is holding a bunch of job opportunities. Beside each opp (in the item template) there's a checkbox that says "apply". After the datalist there's a button that say's "process". I want to LOOP through each datalist entry and see if the user checked the check box. Simple. I wrote the code, but the checked value is ALWAYS False. Any ideas? Here's the code...
2
5523
by: Ceema M via DotNetMonster.com | last post by:
Hello all, I have a nested repeater, which displays categories(parent repeater) and corresponding subcategories(child repeater). Both repeaters have checkboxes. When I check category checkbox and subcategory check boxes and click on submit button , I have to retrieve the corresponding categoryid and subcategory id, so that I can store it to a table. I am getting the categoryid but I am failing to get subcategoryid(actually I don't know...
5
18461
by: rbragg | last post by:
All of my other form data is stored correctly in the db except for my checkbox data. This column in my table is empty. I have this checkbox group on my form: <input name="cbItems" type="checkbox" id="cbItems" value="Item1">Item1 <input name="cbItems" type="checkbox" id="cbItems" value="Item2">Item2 <input name="cbItems" type="checkbox" id="cbItems" value="Item3">Item3 <input name="cbItems" type="checkbox" id="cbItems"...
6
4357
by: Daz | last post by:
Hi everyone. Firstly, I apologise if this i not what you would call a PHP problem. I get quite confused as to what lives in which realm, so if this shouldn't be posted here, please suggest where I should post it. I have created a form, which consists of a list of items, each with a checkbox. When a checkbox is checked or unchecked, the page should be refreshed. During the refresh, the data is validated and the MySQL database is...
10
5209
by: rn5a | last post by:
All the rows in a DataGrid, including the Header, are accompanied with a CheckBox. I want that when the CheckBox in the Header is checked, then all the CheckBoxes should automatically get checked. I set the AutoPostBack property of the CheckBox in the Header to True & am invoking a sub named 'CheckAllRows' on the CheckedChanged event of this CheckBox. The CheckBox in the Header exists within the HeaderTemplate of a TemplateColumn in the...
4
7504
by: mamun | last post by:
Hi All, I have the following situation and am looking for answer in C#. I have a datagrid and putting checkbox next to each record. In the header I have a Delete button. I want users to checkchekboxes and click the Delete button. That will show a confirmation dialog message with the items they choose to delete.
1
1861
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 were possible to create a Javascript function to be saved as a bookmark, and when used it prompts for the checkbox to start at (so it won't discard items that I want to keep) and discards all items after that point. So my main question is, is it...
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...
0
10216
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
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...
1
7543
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
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();...
1
4113
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
2
3728
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
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.