|
 |
asp_databases thread: Checkbox
Message #1 by "chetanp" <chetanpp@h...> on Mon, 26 Nov 2001 18:57:09
|
|
i'm trying to get the checkbox value into an Access 2000-SR1
Access is setup to take in a data type of YES/NO
here is my code:
...
<form action="addcheck3.asp" method="post">
<table>
<tr>
<td><input type="checkbox" name="rm2modem" ></td>
...
</tr>
<table>
<tr>
<td align=center colspan=2><BR><input type="Submit" value="Add Files" >
<input type="Reset"></td>
</tr>
</table
</form>
...
Once they click SUBMIT the info goes to another file:
<html>
<!-- #INCLUDE FILE="dbconnect.asp" -->
<body>
<%
Dim objRec ' recordset object
Set objRec = Server.CreateObject ("ADODB.Recordset")
objRec.Open "RM", strConnect, adOpenStatic, adLockOptimistic, adCmdTable
objRec.AddNew
objRec("rm2modem") = Request.form("rm2modem")
objRec.update
objRec.close
set objRec = nothing
response.redirect "minfo.asp"
%>
</BODY>
</HTML>
this code does not checkbox in the database indiacting this box was CHECKED
Someone please help me on how to get this checkbox to be put into the
database
Message #2 by "Imar Spaanjaars" <Imar@S...> on Mon, 26 Nov 2001 19:04:57
|
|
Hi there,
HTML checkboxes don't return true or false to indicate whether they are
checked or not. A checked checkbox returns "on", while a not checked
checkbox is not in the Request.Form collection.
So, ask for the value, and convert to a valid Access value:
If UCase(Request.Form("rm2modem")) = "ON" then
bRm2Modem = true
else
bRm2Modem = false
end if
Then use the boolean value in your update statement.
You may need to substitute the true / false with 1/0. Not sure how Access
handles this.
HtH
Imar
> i'm trying to get the checkbox value into an Access 2000-SR1
> Access is setup to take in a data type of YES/NO
> here is my code:
>
> ...
> <form action="addcheck3.asp" method="post">
> <table>
> <tr>
> <td><input type="checkbox" name="rm2modem" ></td>
> ...
> </tr>
> <table>
> <tr>
> <td align=center colspan=2><BR><input type="Submit" value="Add Files" >
> <input type="Reset"></td>
> </tr>
> </table
> </form>
> ...
>
>
> Once they click SUBMIT the info goes to another file:
> <html>
> <!-- #INCLUDE FILE="dbconnect.asp" -->
> <body>
> <%
> Dim objRec ' recordset object
> Set objRec = Server.CreateObject ("ADODB.Recordset")
> objRec.Open "RM", strConnect, adOpenStatic, adLockOptimistic, adCmdTable
> objRec.AddNew
> objRec("rm2modem") = Request.form("rm2modem")
> objRec.update
> objRec.close
> set objRec = nothing
> response.redirect "minfo.asp"
> %>
> </BODY>
> </HTML>
>
>
> this code does not checkbox in the database indiacting this box was
CHECKED
> Someone please help me on how to get this checkbox to be put into the
> database
Message #3 by Kyle Burns <kburns@c...> on Mon, 26 Nov 2001 14:01:33 -0500
|
|
You need to use the VALUE property of the checkbox:
<input type="checkbox" name="rm2modem" value="true">
In your processing page, you can now check the value of the input (this will
be blank if the control was not checked) and update your record accordingly:
If Request.Form("rm2modem") = "true" Then
objRec("rm2modem") = True
Else
objRec("rm2modem") = False
End If
=================================
Kyle M. Burns, MCSD, MCT
ECommerce Technology Manager
Centra Credit Union
kburns@c...
-----Original Message-----
From: chetanp [mailto:chetanpp@h...]
Sent: Monday, November 26, 2001 1:57 PM
To: ASP Databases
Subject: [asp_databases] Checkbox
i'm trying to get the checkbox value into an Access 2000-SR1
Access is setup to take in a data type of YES/NO
here is my code:
...
<form action="addcheck3.asp" method="post">
<table>
<tr>
<td><input type="checkbox" name="rm2modem" ></td>
...
</tr>
<table>
<tr>
<td align=center colspan=2><BR><input type="Submit" value="Add Files" >
<input type="Reset"></td>
</tr>
</table
</form>
...
Once they click SUBMIT the info goes to another file:
<html>
<!-- #INCLUDE FILE="dbconnect.asp" -->
<body>
<%
Dim objRec ' recordset object
Set objRec = Server.CreateObject ("ADODB.Recordset")
objRec.Open "RM", strConnect, adOpenStatic, adLockOptimistic, adCmdTable
objRec.AddNew
objRec("rm2modem") = Request.form("rm2modem")
objRec.update
objRec.close
set objRec = nothing
response.redirect "minfo.asp"
%>
</BODY>
</HTML>
this code does not checkbox in the database indiacting this box was CHECKED
Someone please help me on how to get this checkbox to be put into the
database
$subst('Email.Unsub')
Message #4 by "Tomm Matthis" <matthis@b...> on Mon, 26 Nov 2001 15:48:10 -0500
|
|
The value rm2modem will ONLY be present if they have checked the value...
otherwise it will not be in the forms collection... also, you have to
interpret the value and set it to 0 or 1 for the field.
Also, you create a SQL INSERT statement instead of using a recordset ADDNEW to
do this.
-- Tomm
> -----Original Message-----
> From: chetanp [mailto:chetanpp@h...]
> Sent: Monday, November 26, 2001 6:57 PM
> To: ASP Databases
> Subject: [asp_databases] Checkbox
>
>
> i'm trying to get the checkbox value into an Access 2000-SR1
> Access is setup to take in a data type of YES/NO
> here is my code:
>
> ...
> <form action="addcheck3.asp" method="post">
> <table>
> <tr>
> <td><input type="checkbox" name="rm2modem" ></td>
> ...
> </tr>
> <table>
> <tr>
> <td align=center colspan=2><BR><input type="Submit" value="Add Files" >
> <input type="Reset"></td>
> </tr>
> </table
> </form>
> ...
>
>
> Once they click SUBMIT the info goes to another file:
> <html>
> <!-- #INCLUDE FILE="dbconnect.asp" -->
> <body>
> <%
> Dim objRec ' recordset object
> Set objRec = Server.CreateObject ("ADODB.Recordset")
> objRec.Open "RM", strConnect, adOpenStatic, adLockOptimistic, adCmdTable
> objRec.AddNew
> objRec("rm2modem") = Request.form("rm2modem")
> objRec.update
> objRec.close
> set objRec = nothing
> response.redirect "minfo.asp"
> %>
> </BODY>
> </HTML>
>
>
> this code does not checkbox in the database indiacting this box was CHECKED
> Someone please help me on how to get this checkbox to be put into the
> database
>
> $subst('Email.Unsub')
>
|
|
 |