p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

asp_databases thread: checkbox with database


Message #1 by "liron" <liron10@n...> on Sat, 15 Jul 2000 23:59:32
i have  a problem with checkbox  whan i mark one of my checkbox and i want

to send what i mark to the database it canot send it to the  database

my script is this:



<%@ Language=VBScript %>

<%

Option Explicit

Response.Expires = 0

%>

<!--#include file="adovbs.inc"-->

<%

Dim objConn, strConn, objRS







Set objConn = Server.CreateObject("ADODB.Connection")

strConn = "DSN=Exams1;UID=sa;PWD=;"

objConn.Open strConn

Set objRS = Server.CreateObject("ADODB.Recordset")



 If Request.ServerVariables("QUERY_STRING")<> "" Then



      objRS.CursorLocation = adUseServer

      objRS.CursorType = adOpenKeyset

      objRS.LockType = adLockOptimistic

      objRS.Open "qcheck", objConn, , , adCmdTable

      objRS.AddNew

      if Request.QueryString("checkbox") then

            

      if Request.QueryString("n1") then

      objRS("Ans1") = true

      else

      objRS("Ans1") = false

      end if 

      if Request.QueryString("n2") then

      objRS("Ans2")=true

      else

      objRS("Ans2")=false

      end if

      if Request.QueryString("n3") then

      objRS("Ans3")=true

      else 

      objRS("Ans3")=false

      end if

      if Request.QueryString("n4") then

      objRS("Ans4")=true

      else

      objRS("Ans4")=false

      end if

      objRS.Update

      objRS.Close

     



 



end if

End IF



 





%>

<HTML>

<BODY>

<FORM ACTION="" METHOD=GET>

 asnser1:<INPUT type="checkbox"  name=checkbox1 value"n1"><br><br>

 asnser2: <INPUT type="checkbox"  name=checkbox1 value="n2"><br><br>

 asnser3:  <INPUT type="checkbox"  name=checkbox1 value="n3"><br><br>

 asnser4:   <INPUT type="checkbox"  name=checkbox1 value="n4"><br><br>

             <INPUT type="submit" value="Submit" id=submit1 name=submit1>

             <INPUT type="reset" value="Reset" id=reset1 name=reset1>

</FORM>

<a href=admin2.asp>back</a>

</BODY>

</HTML>





please help me!

Message #2 by "Ken Schaefer" <ken.s@a...> on Mon, 17 Jul 2000 18:35:46 +1000
You have to swap the names and values around...



<input type="checkbox" name="n1" value="true">

<input type="checkbox" name="n2" value="true">

...etc...



Then the rest of your code will work.



Cheers

Ken



----- Original Message -----

From: "liron" 

To: "ASP Databases" <asp_databases@p...>

Sent: Saturday, July 15, 2000 11:59 PM

Subject: [asp_databases] checkbox with database





> i have  a problem with checkbox  whan i mark one of my checkbox and i want

> to send what i mark to the database it canot send it to the  database

> my script is this:

>

> <%@ Language=VBScript %>

> <%

> Option Explicit

> Response.Expires = 0

> %>

> <!--#include file="adovbs.inc"-->

> <%

> Dim objConn, strConn, objRS



<snipped for your viewing comfort>




  Return to Index