need help- Submitting Check Box values to Table
need help- Submitting Check Box values to Table
am 15.06.2006 20:39:10 von GabrielESandoval
im trying to make an online survey. the answers are different check
boxes.
I have this written out already. maybe you guys can help.
ill give you the abbreviated sample of it:
-------
Sample
<%
strFilePath = server.MapPath("database.mdb")
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strFilePath
& ";"
Set rst = Server.CreateObject("ADODB.Recordset")
rst.LockType = 2
%>
<%
'opening database connection
'add record to my table
FUNCTION WriteToFile()
strSQL = "SELECT * FROM Table1"
rst.Open strSQL, strConn
rst.addnew
rst("ID#") = request.form ("ID#")
rst("Name") = request.form ("Name")
rst("Box1") = request.form ("Box2")
rst("Box2") = request.form ("Box2")
rst.Update
rst.Close
End Function
%>
--------
This is a short sample of the code i have. When i try it the page
reloads and the answers reset but the info is ot going to the database.
i know im missing the action=___ whenever i declare my form but i dont
know what to put or if what im missing that will make mine work.
eventually i will work on validating it but for know can someone pleae
help
Re: need help- Submitting Check Box values to Table
am 15.06.2006 20:52:01 von James Jones
Ok. i think i know what you want.......
say your page is named TEST.ASP.........set your form to that........when i
do pages like this, that use forms, i create a varible that tells the page
what to do.....such as............
<%
func = Request.Form("func")
IF func = "" Then
%>
<%
End IF
IF func = "submitForm" Then
strFilePath = server.MapPath("database.mdb")
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strFilePath
& ";"
Set rst = Server.CreateObject("ADODB.Recordset")
rst.LockType = 2
%>
<%
'opening database connection
'add record to my table
strSQL = "SELECT * FROM Table1"
rst.Open strSQL, strConn
rst.addnew
rst("ID#") = request.form ("ID#")
rst("Name") = request.form ("Name")
rst("Box1") = request.form ("Box2")
rst("Box2") = request.form ("Box2")
rst.Update
rst.Close
End IF
%>
give that a shot...........hope it works, if not, sorry
"Gaby" wrote in message
news:1150396750.231560.114900@r2g2000cwb.googlegroups.com...
> im trying to make an online survey. the answers are different check
> boxes.
> I have this written out already. maybe you guys can help.
> ill give you the abbreviated sample of it:
>
> -------
>
>
>
>
>
> Sample
>
>
>
>
> <%
>
>
> strFilePath = server.MapPath("database.mdb")
>
> strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strFilePath
> & ";"
> Set rst = Server.CreateObject("ADODB.Recordset")
> rst.LockType = 2
>
> %>
>
> <%
> 'opening database connection
>
> 'add record to my table
>
> FUNCTION WriteToFile()
> strSQL = "SELECT * FROM Table1"
> rst.Open strSQL, strConn
>
> rst.addnew
>
> rst("ID#") = request.form ("ID#")
> rst("Name") = request.form ("Name")
>
>
>
> rst("Box1") = request.form ("Box2")
> rst("Box2") = request.form ("Box2")
>
>
>
> rst.Update
> rst.Close
> End Function
> %>
>
>
>
>
>
> --------
>
> This is a short sample of the code i have. When i try it the page
> reloads and the answers reset but the info is ot going to the database.
> i know im missing the action=___ whenever i declare my form but i dont
> know what to put or if what im missing that will make mine work.
> eventually i will work on validating it but for know can someone pleae
> help
>
Re: need help- Submitting Check Box values to Table
am 15.06.2006 22:46:58 von GabrielESandoval
I am now getting a syntax error (Microsoft VBScript compilation error
'800a03ea' )for the line that says
James Jones wrote:
----> IF func = "submitForm" Then
>
> strFilePath = server.MapPath("database.mdb")
any ideas?
thanks for the help so far. i understood the changes you made.
Re: need help- Submitting Check Box values to Table
am 15.06.2006 22:48:22 von GabrielESandoval
i get a syntax error (Microsoft VBScript compilation error '800a03ea' )
on this line----> IF func = "submitForm" Then
>
> strFilePath = server.MapPath("database.mdb")
any ideas?
thanks for your help so far.
gabriel
Re: need help- Submitting Check Box values to Table
am 15.06.2006 22:57:56 von James Jones
ok........then we will do an ELSE intead of another IF....................
<%
ELSE
strFilePath = server.MapPath("database.mdb")
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strFilePath
& ";"
Set rst = Server.CreateObject("ADODB.Recordset")
rst.LockType = 2
'opening database connection
'add record to my table
strSQL = "SELECT * FROM Table1"
rst.Open strSQL, strConn
rst.addnew
rst("ID#") = request.form ("ID#")
rst("Name") = request.form ("Name")
rst("Box1") = request.form ("Box2")
rst("Box2") = request.form ("Box2")
rst.Update
rst.Close
End IF
%>
"Gaby" wrote in message
news:1150404502.879585.88860@i40g2000cwc.googlegroups.com...
>i get a syntax error (Microsoft VBScript compilation error '800a03ea' )
> on this line----> IF func = "submitForm" Then
> >
> > strFilePath = server.MapPath("database.mdb")
>
> any ideas?
> thanks for your help so far.
>
> gabriel
>
Re: need help- Submitting Check Box values to Table
am 20.06.2006 20:04:09 von GabrielESandoval
I tried many different variations and I cant get this to work. If any
of you experts are up for it, I wouldnt mind emailing you my code.
Many having someone else proof read it I may find something wrong. I
did i noticed when I submit the form and if i hit REFRESH i get "The
page cannot be refreshed without sending the information". So theres
got to be something with the connection i would think. Email me if you
wouldnt mind helping me out and i will send what I got to you.
Thanks.
Gabriel
Re: need help- Submitting Check Box values to Table
am 20.06.2006 23:58:51 von Mike Brind
Gaby wrote:
> im trying to make an online survey. the answers are different check
> boxes.
> I have this written out already. maybe you guys can help.
> ill give you the abbreviated sample of it:
>
> -------
>
>
>
>
>
> Sample
> <%
> strFilePath = server.MapPath("database.mdb")
>
> strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strFilePath
> & ";"
> Set rst = Server.CreateObject("ADODB.Recordset")
> rst.LockType = 2
>
> %>
>
> <%
> 'opening database connection
>
> 'add record to my table
>
> FUNCTION WriteToFile()
> strSQL = "SELECT * FROM Table1"
> rst.Open strSQL, strConn
>
> rst.addnew
>
> rst("ID#") = request.form ("ID#")
> rst("Name") = request.form ("Name")
>
>
>
> rst("Box1") = request.form ("Box2")
> rst("Box2") = request.form ("Box2")
>
>
>
> rst.Update
> rst.Close
> End Function
> %>
>
>
>
>
>
> --------
>
> This is a short sample of the code i have. When i try it the page
> reloads and the answers reset but the info is ot going to the database.
> i know im missing the action=___ whenever i declare my form but i dont
> know what to put or if what im missing that will make mine work.
> eventually i will work on validating it but for know can someone pleae
> help
To start with, don't create a recordset to add a new record. Second,
you have a javascript call to a function - onClick="WriteToFile() -
calling server side asp code. That won't work. Third, you are trying
to reference an input called Name that doesn't exist on your form.
Here's your form:
In the same page, do this:
<%
On Error Resume Next
If Request.Form("Action") = "Submit" Then
strFilePath = server.MapPath("database.mdb")
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strFilePath
conn.open strConn
p1 = Request.Form("Instructor")
p2 = clng(Request.Form("ID#"))
p3 = cint(Request.Form("Box1"))
p4 = cint(Request.Form("Box2"))
If Err.Number<>0 Then
Response.Write "Your record has not been added"
Else
conn.qInsertRecord p1, p2, p3, p4
Response.Write "Your record has been added"
End If
End If
%>
Now, in your database, go to the Query pane and select New Query in
Design View. Close the Show Tables dialogue box that opens, then click
the SQL button in the top left. In the new window that opens, copy
this in, making the necessary changes for your table and field names:
INSERT INTO Table1 (ID#, Instructor, Box1, Box2) VALUES ([p1], [p2],
[p3], [p4])
Save that as qInsertRecord. Then run the query and enter values as
prompted to make sure it works. If it does, that's it. You're done.
--
Mike Brind
Re: need help- Submitting Check Box values to Table
am 22.06.2006 19:46:29 von GabrielESandoval
Mike I took what you wrote and made some changes to alter it some....
Bottom Line: IT WORKED GREAT.
Thanks again for your help.
Gabriel