Ask a Question related to ASP, Design and Development.
-
Frank Collins #1
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 (" &
& "," & intNOz & "," & intMAYBEz & ")">arrayQuestionID(i) & "," & intCompanyID & "," & intYESz
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
Frank Collins Guest
-
Dynamic Checkboxes
This is a rather simple situation that is killing my brain, maybe because I'm working on a Sunday night?! Anyhow, I am running a query against my... -
Help on processing a dynamic set of checkboxes
Hello everyone! I am having a doozy of a time trying to figure out how to process some checkboxes that are dynamically created. Here is my... -
Deselecting dynamic checkboxes
I am quering a database that dynamically creates a table with three columns. The first column is the ID, the second is the title of the document and... -
Insert Records from checkboxes
Hi, I would like to be able to insert multiple records into a database using checkboxes. A query is used to display the checkboxes. How can... -
Dynamic checkboxes and INSERT into DB
"Frank Collins" <fcollins@mhca.com> wrote in message news:094101c352a8$7ca66990$a401280a@phx.gbl... Hmm..so you get your companyID on the same...



Reply With Quote

