472,353 Members | 1,026 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,353 software developers and data experts.

checkboxes and other form inserts into a database

Hello experts,

I need a hand. On my asp submit page I have the following code:
Expand|Select|Wrap|Line Numbers
  1.  
  2. for i = 1 to 5 ' 5 question form'
  3.  
  4. Question = Request.Form("Q" & i)
  5. Answer = Request.Form("A" & i)
  6. Comment  = Request.Form("C" & i )
  7.  
  8. ValComment = Replace(Comment, "'", "''")
  9. ValAnswer = Replace(Answer, "'", "''")
  10.  
  11. checkbox = Request.Form("check")
  12. checkbox = Split(checkbox,", ")
  13. -----------------------------------------------------------------------------------------
  14. Set oConn = Server.CreateObject("ADODB.Connection")
  15. oConn.Open "removed for security reasons"
  16. set sSQL = server.CreateObject ("ADODB.Recordset")
  17. set sSQL1 = server.CreateObject ("ADODB.Recordset")
  18. --------------------------------------------------------------------------------------------
  19. IF........somthing here in the checkbox = STRUGGLING HERE please help
  20. sSQL = "INSERT into Table (ID, Question, Answer, Comments, TimeStamp,
  21. UserID)"
  22. sSQL = sSQL &  "VALUES (Test_seq.nextval, '" & Question &"', '" &
  23. checkbox &"', '" & ValComment &"', sysdate, '"& User & "')"
  24.  
  25. Else
  26. sSQL1 = "INSERT into table (ID, Question, Answer, Comments, TimeStamp,
  27. UserID)"
  28. sSQL1 = sSQL1 &  "VALUES (Test_seq.nextval, '" & Question &"', '" &
  29. ValAnswer &"', '" & ValComment &"', sysdate, '"& User & "')"
  30. response.write ssql1 & "<BR>"
  31. End IF
  32. Next
  33. response.end
  34.  
Note: just the bulk of the code has been added so that you get an idea
of what it is that I am talking about.

On my html form I have a combination of dropdownlists and combo
boxes. The checkboxes all have the same name. It is basically 1
question checkbox with the ability to choose 5 answers. I have a
total of 5 questions(1 checkbox question and 3 drop downs and 1
textbox. What I am struggling with is how do I get the answers from
the checkboxes into the database as well as the other form elements.
If it is much easier to not parse the comma separated list then so be
it:) Thanks everyone.

Mar 27 '07 #1
1 2583

"MrHelpMe" <cl********@hotmail.comwrote in message
news:11**********************@n59g2000hsh.googlegr oups.com...
Hello experts,

I need a hand. On my asp submit page I have the following code:
Expand|Select|Wrap|Line Numbers
  1. for i = 1 to 5 ' 5 question form'
  2. Question = Request.Form("Q" & i)
  3. Answer = Request.Form("A" & i)
  4. Comment  = Request.Form("C" & i )
  5. ValComment = Replace(Comment, "'", "''")
  6. ValAnswer = Replace(Answer, "'", "''")
  7. checkbox = Request.Form("check")
  8. checkbox = Split(checkbox,", ")
  9. -----------------------------------------------------------------------------------------
  10. Set oConn = Server.CreateObject("ADODB.Connection")
  11. oConn.Open "removed for security reasons"
  12. set sSQL = server.CreateObject ("ADODB.Recordset")
  13. set sSQL1 = server.CreateObject ("ADODB.Recordset")
  14. --------------------------------------------------------------------------------------------
  15. IF........somthing here in the checkbox = STRUGGLING HERE please help
Expand|Select|Wrap|Line Numbers
  1.  
  2. if checkbox(0) = correct answer then
  3.  
  4.  
  5.         
  6.                 sSQL = "INSERT into Table (ID, Question, Answer, Comments, TimeStamp,
  7. UserID)"
  8. sSQL = sSQL &  "VALUES (Test_seq.nextval, '" & Question &"', '" &
  9. checkbox &"', '" & ValComment &"', sysdate, '"& User & "')"
  10.  
  11. you have set sSQL to be a recordset. now you are treating it as a string.
  12.  
  13.  
  14. a recordset is for reading from a database, not for writting to it.
  15.  
  16. you need somthing like this
  17.  
  18. sql = "your sql statement"
  19.  
  20. cn.open "your connection string"
  21. cn.execute(sql)
  22. cn.close
  23.  
  24.  
  25.  
  26.  
  27.  
  28.         
  29.                 >
  30. Else
  31. sSQL1 = "INSERT into table (ID, Question, Answer, Comments, TimeStamp,
  32. UserID)"
  33. sSQL1 = sSQL1 &  "VALUES (Test_seq.nextval, '" & Question &"', '" &
  34. ValAnswer &"', '" & ValComment &"', sysdate, '"& User & "')"
  35. response.write ssql1 & "<BR>"
  36. End IF
  37. Next
  38. response.end
  39.  
  40.  
>
Note: just the bulk of the code has been added so that you get an idea
of what it is that I am talking about.

On my html form I have a combination of dropdownlists and combo
boxes. The checkboxes all have the same name. It is basically 1
question checkbox with the ability to choose 5 answers. I have a
total of 5 questions(1 checkbox question and 3 drop downs and 1
textbox. What I am struggling with is how do I get the answers from
the checkboxes into the database as well as the other form elements.
If it is much easier to not parse the comma separated list then so be
it:) Thanks everyone.
Apr 4 '07 #2

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

Similar topics

4
by: Pete | last post by:
Okay, I'm still stuck with this problem. Here's a quick recap/summary :- 1. Page 1:User checks 3 out of 10 checkboxes and submits form to page 2...
0
by: Frank Collins | last post by:
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...
2
by: Renie83 | last post by:
What I have are two pages. One is a form with some input boxes and check boxes on it. It is posting to a different script page that inserts into a...
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....
3
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...
1
by: zoneal | last post by:
Hello there, Currently I am working with the project which needs dynamically generated checkboxes and i have generated dynamic checkboxes but...
1
by: TechnoAtif | last post by:
Hi to all. I have got a form containing of checkboxes along with other items. I have simply no clue as to (i) how to make entry for those...
0
markrawlingson
by: markrawlingson | last post by:
It seems that a lot of people run into this issue in regards to dealing with the result that checkboxes return to the Request.Form object. So this...
13
beacon
by: beacon | last post by:
Hi everybody, I have a quality assurance database that has a form with a bunch of checkboxes on it that serve as reasons for why a product...
1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS...

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.