Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    May 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    ASP - check boxes/option boxes

    sorry I am really new to this. I have been working with a check box which has been working, I then wanted to extend this to include option boxes which I couldn't do so decided to use more check boxes - however, I cannot get this to work. Can anyone let me know why (sorry) also any help with perhaps changing this so that I could use option boxes would also be great. The files are below are attached to an access database.

    [code]

    <html>
    <head>
    <title>Guestbook Form</title>
    </head>
    <body bgcolor="yellow" text="black">

    <h1>Rate our website</h1>

    Please complete the feedback form below


    <center>
    <form name = "form" method = "post" action = "add_to_register.asp">

    <table cellpadding= 5px style= "background-color:#b0d8ff;border:1px solid navy;">
    <tr><td width = "50%">First Name</td><td><input name = 'firstname' type = "text" size = "40" maxlength = "200"/></td></tr>
    <tr><td width = "50%">Surname</td><td><input name = 'surname' type = "text" size = "40" maxlength = "200"/></td></tr>


    <tr><td width = "50%">Age</td><td><input name = 'age' type = "text"
    size = "40" maxlength = "200"/></td></tr>


    <tr><td width = "50%">How do you rate our website</td>


    <tr><td width = "50%">Easy to use</td><td style = 'text-align: center'>
    <input type = 'checkbox' name = 'use' /></td></tr>

    <tr><td width = "50%">Entertaining</td><td style = 'text-align: center'>
    <input type = 'checkbox' name = 'entertaining' /></td></tr>

    <tr><td width = "50%">Informative</td><td style = 'text-align: center'>
    <input type = 'checkbox' name = 'informative' /></td></tr>

    <tr><td width = "50%">suggestions</td><td><input name = 'suggestions' type = "text" size = "40" maxlength = "200"/></td></tr>


    </table>
    <br />
    <button type = "submit">Submit</button>
    </form>
    </center>


    </body>
    </html>

    [code]

    [code]

    <%
    'Dimension variables
    Dim adoCon
    Dim rsAddRatings

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

    ' the Access Driver is very very old and very buggy...you really should use JET OLEDB
    adoCon.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source = " & Server.MapPath("Ratings.mdb")

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

    ' when you use ADDNEW, you should use the whole table, not just SELECT some fields
    ' so no SQL query

    ' cursor type 2 is not properly usable with ASP code...type 3 is much better
    ' and no reason to set cursor type and lock type ahead of time...

    ' open the recordset using just the name of the table; set cursor type and lock type at same time:
    rsAddRatings.Open "tblratings", adoCon, 3, 3

    'Tell the recordset we are adding a new record to it
    rsAddRatings.AddNew

    'Add a new record to the recordset
    rsAddRatings.Fields("Firstname") = Request.Form("firstname")
    rsAddRatings.Fields("Surname") = Request.Form("surname")
    rsAddRatings.Fields("Age") = Request.Form("age")





    ' this assumes the Register field ind DB is a boolean (YES/NO) field:
    ' the comparison of <> "" will only only be true if the field was checked
    rsAddRatings.Fields("Use") = ( TRIM(Request.Form("use")) <> "" )
    rsAddRatings.Fields("Entertaining") = ( TRIM(Request.Form("entertaining")) <> "" )
    rsAddRatings.Fields("Informative") = ( TRIM(Request.Form("informative")) <> "" )


    rsAddRatings.Fields("Suggestions") = Request.Form("suggestions")

    rsAddRatings.Update
    rsAddRatings.Close
    adoCon.Close

    ' instead of redirecting, just include the message here...faster by a long shot!

    %>
    <!-- #include file="complete_message.html" -->
    <html>
    message complete
    </html>

    [code]

    Any help and advice would be very much appreciated.

  • #2
    New to the CF scene
    Join Date
    May 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile

    sorry for anyone who has spent time looking at my code, as if by magic, the code has now started to work. Thank you for time and attention.

    Debbie


  •  

    Posting Permissions

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