SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Zealot
    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

  2. #2
    Sultan of Ping jofa's Avatar
    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...

  3. #3
    \m/ R.I.P. Dimebag! \m/ JimBolla's Avatar
    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

  4. #4
    SitePoint Zealot
    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

  5. #5
    \m/ R.I.P. Dimebag! \m/ JimBolla's Avatar
    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

  6. #6
    SitePoint Zealot
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •