SitePoint Sponsor |
|
User Tag List
Results 1 to 6 of 6
Thread: Checkbox problems
-
Sep 16, 2002, 07:39 #1
- Join Date
- Jul 2002
- Location
- South-West UK
- Posts
- 100
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Checkbox problems
Hi all,
I'm having problems passing values from a form to insert them into a database:
The form checkbox on the form itself is:
------------------------------------
<input type="checkbox" name="expertise_general" value="1">
------------------------------------
This gets passed (posted) to a preview page:
---------------------------------------------
<%
Dim expertise_general
expertise_general = Request.form( "expertise_general" )
%>
<html>
<form method="post" action="send2.asp">
<input type="hidden" name="action" value="register">
<table>
<tr>
<td>Expertise qualities/td>
<td><%=expertise_general%></td>
<td>
<input type="hidden" name="expertise_general" value="<%=expertise_general%>"></td>
</tr>
<input type="submit" value="Submit" name="submit">
</table>
</html>
----------------------------------------------
The page that adds the info to the database has this at the top:
-------------------------------------------------
<% @LANGUAGE = VBSCRIPT %>
<%
If request("action") = "register" Then
username=trim(request("username"))
<!--#include file="inc-dbconnection.asp"-->
<%
set Rs=server.Createobject("ADODB.RECORDSET")
sql="SELECT * FROM table_name WHERE username='"&username&"'"
Rs.Open sql,objConn,1,3
If rs.eof Then
rs.AddNew
If request("expertise_general") Then rs("expertise_general") = 1
rs.Update
rs.close
set rs = nothing
objConn.close
set objConn = nothing
response.Redirect "thankyou_1.asp"
Else
response.Redirect "sorry_password.asp"
End If
Else
%>
-------------------------------------------
I'm getting an error:
Error Type:
Microsoft VBScript runtime (0x800A000D)
Type mismatch: '[string: ""]'
/
---------------------------------------
^ and this is pointing to the line which handles the entry of the checkbox infor on the page that submits it to the database.
Any ideas anyone?
Matt
-
Sep 16, 2002, 08:34 #2
- Join Date
- Mar 2002
- Location
- Svíþjóð
- Posts
- 4,080
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Try
If Request("expertise_general") <> "" Then...
or
If Request("expertise_general") = "1" Then...
-
Sep 16, 2002, 08:34 #3
- Join Date
- Dec 2001
- Location
- erie, pa
- Posts
- 1,130
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
which line is getting the error? btw, if you put [ code ] [ /code ](w/o the spaces) tags around your code, it will format it nicer for those of us trying to help
-- JIM BOLLA
Wanna play Halo 2? My XBOX Live gamertag: crowdozer
-
Sep 16, 2002, 08:40 #4
- Join Date
- Jul 2002
- Location
- South-West UK
- Posts
- 100
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I'm getting an error on the line that's got:
If request("expertise_general") Then rs("expertise_general") = 1
-
Sep 16, 2002, 08:43 #5
- Join Date
- Dec 2001
- Location
- erie, pa
- Posts
- 1,130
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
ah. request("expertise_general") probably won't evaluate to a boolean expression because it is a string value. try:
Code:If request("expertise_general") <> "" Then ...
-- JIM BOLLA
Wanna play Halo 2? My XBOX Live gamertag: crowdozer
-
Sep 16, 2002, 08:52 #6
- Join Date
- Jul 2002
- Location
- South-West UK
- Posts
- 100
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi Crowdozer and Jofa,
Thanks for your help.....worked fine.. cheers
Matt
Bookmarks