473,396 Members | 2,002 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,396 software developers and data experts.

Dynamic checkboxes & INSERT into DB

Can anyone point me to some good examples on the web of
using values from dynamically created checkboxes on forms
in ASP, particularly relating to INSERTING those values
into a SQL or Access database?

Basically, I have a form on which I have a series of
statements, with 3 checkboxes for each statement - YES,
NO, MAYBE. This series of statements is being dynamically
populated from a query of a table in Access,
called "tblQuestions". In the form, I created a hidden
field named "QuestionID" to return the QuestionID. The
checkboxes are named YESz, NOz, and MAYBEz, and set to
return a value of "ON" if checked.

I created another table called "tblQuestionAnswers" into
which I want to insert records, in which I have 6 fields -
1) QAID - an autonumber primary index field, 2)
QuestionID, 3) CompanyID, 4) YesZ, 5) NOz, 6) MAYBEz - the
z is used to reduce the risk of complications from any
reserved fields.

In my update ASP code page, I defined the variables from
the form, and set 3 IF/THEN statements to resolve any NULL
issues with the checkboxes:

IF(IsNull(Request.Form("YESz"))) Then
YESz = 0
Else
YESz = 1
End IF

Etc., for all 3 checkboxes.

Then I tried to create an array and a database connection
to INSERT:

Dim arrayQuestionID
Dim arrayCompanyID
Dim arrayYESz
Dim arrayNOz
Dim arrayMAYBEz
Dim i

arrayQuestionID = split(QuestionID,",")
arrayCompanyID - split(CompanyID,",")
arrayYESz = split(YESz,",")
arrayNOz = split(NOz,",")
arrayMAYBEz = split(MAYBEz,",")

for i = 0 to ubound(arrayQuestionID)
intCompanyID = arrayCompanyID(i)
intYESz = arrayYESz(i)
intNOz = arrayNOz(i)
intMAYBEz = arrayMAYBEz(i)

set myConn=Server.CreateObject("adodb.connection")
myConn.Open "DB"
myConn.Execute "INSERT INTO tblQuestionAnswers
(QuestionID,CompanyID,YESz,NOz,MAYBEz) VALUES (" &
arrayQuestionID(i) & "," & intCompanyID & "," & intYESz

& "," & intNOz & "," & intMAYBEz & ")"
intCompanyID(i)
intSvcOffering(i)
intSvcExemplary(i)
intSvcInterested(i)
Next
myConn.Close
set myConn = Nothing

Basically, I'm now getting a type mismatch error during
the INSERT process. At other times, trying other things, I
have gotten a "Subscript out of range" error. And I'm not
really sure that the thing is iterating over the array,or
if I have the array properly written.

Obviously, I have failed to do something properly! LOL
I've been stuck on this issue for 3 days. Any help that
anyone can give me will be GREATLY APPRECIATED! LOL

"I am an ASP newbie, therefore an ASP ignoramus!" LOL

---------------
Frank Collins
Jul 19 '05 #1
0 3707

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

Similar topics

3
by: jason | last post by:
How does one loop through the contents of a form complicated by dynamic construction of checkboxes which are assigned a 'model' and 'listingID' to the NAME field on the fly in this syntax:...
6
by: middletree | last post by:
I have a page which has something like 100 checkboxes, in three categories, so I chose to build the checkboxes into the page like this: <% strSQL = "SELECT PeopleID, PeopleDesc " strSQL =...
1
by: middletree | last post by:
Hate to post this in a separate post, but felt that the last thread was too far down to get noticed. It is called dynamic checkboxes, and it contained some good advice for me, but it led to...
8
by: DylanM | last post by:
I have some checkboxes that are generated from the results of a database search. At the moment, the checkboxes are part of a table making up a form. Users are going through the form, clicking the...
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...
1
by: Kevin R | last post by:
This is one of the weirdest problems I have ever run into. I have had to trim down a bunch of code to give a sample that is more easily readable by those who will view this. Here is the problem:...
2
by: assgar | last post by:
Hi Developemnt on win2003 server. Final server will be linux Apache,Mysql and PHP is being used. I use 2 scripts(form and process). The form displays multiple dynamic rows with chechboxs,...
7
by: Jerim79 | last post by:
My situation is that I have a form that asks the user for a number. Next, I execute a while loop that displays a group of questions the amount of times the customer entered. For instance, the loop...
2
by: AlexanderDeLarge | last post by:
Hi! I got a problem that's driving me crazy and I'm desperately in need of help. I'll explain my scenario: I'm doing a database driven site for a band, I got these tables for their discography...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
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,...

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.