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 13 of 13
  1. #1
    Regular Coder
    Join Date
    Nov 2005
    Posts
    750
    Thanks
    138
    Thanked 1 Time in 1 Post

    HTML validator with ASP

    Hello

    This is probably not strictly an ASP question, but an HTML online validator is giving me a whole number of errors concerning my use of <tr> and <td> in the following:

    Code:
    response.write "<table width='100%' border='1'>"
    %>
    
    <tr class="headerRow">
                    <td>ID</td>
    		<td >First Name</td>
    		<td >Last Name</td>
    		<td >Wolf ID</td>
    		<td >Tel No</td>
                    <td >Address</td>
    		<td >City</td>
    		<td >Postcode</td>
    		<td >Items</td>
    		<td >Received</td>
    		<td >Dispatched</td></font>
        </tr>
    
    <%
    'Determine whether there are any records
     If Recordset.EOF Then
     Response.Write "<tr><td>No records returned.</td></tr>"
     Else
    'If there are records then loop through the fields and format in table rows & cells
    
    
    Do While Not recordset.EOF
    
    
    Response.Write "<td>" & recordset("ID") & "</td>"
    Response.Write "<td>" & recordset("firstName") & "</td>"
    Response.Write "<td>" & recordset("lastName") & "</td>"
    Response.Write "<td>" & recordset("wolfID") & "</td>"
    Response.Write "<td>" & recordset("telNo") & "</td>"
    Response.Write "<td>" & recordset("stAddress") & "</td>"
    Response.Write "<td>" & recordset("city") & "</td>"
    Response.Write "<td>" & recordset("postCode") & "</td>"
    Response.Write "<td>" & recordset("items") & "</td>"
    Response.Write "<td>" & recordset("received") & "</td>"
    Response.Write "<td>" & recordset("dispatched") & "</td></tr>" 
    
    'move on to the next record
     Recordset.MoveNext
     Loop
    'Close the HTML table
     response.write "</table>"
     End If
    After 'Do While Not recordset.EOF', there is no <tr> opening tag and there are no table row opening and closing tags for each of the response.write statements.

    Is that because the page displayed is taking its cue from the columns and rows of the database itself? If so, how to get round the HTML validator?

    Thanks

  • #2
    Senior Coder DanInMa's Avatar
    Join Date
    Nov 2010
    Location
    Salem,Ma
    Posts
    1,577
    Thanks
    13
    Thanked 248 Times in 248 Posts
    if you did your validation on a processed page, then you need to change

    Code:
    Response.Write "<td>" & recordset("ID") & "</td>"
    to
    Code:
    Response.Write "<tr><td>" & recordset("ID") & "</td>"
    if you are running validation on yoru asp source code, then you shouldnt be. have it validate a valid url for your page or paste in the resulting html from the source of your page as viewed in a web browser

  • Users who have thanked DanInMa for this post:

    SteveH (09-13-2013)

  • #3
    Regular Coder
    Join Date
    Nov 2005
    Posts
    750
    Thanks
    138
    Thanked 1 Time in 1 Post
    Thank you, DaniaMa

    That's a lot better - it doesn't make any difference to the way the page is presented online, but the HTML validator has gone from showing me 26 errors (!) to 2 errors.

    Much appreciated.

    Steve

  • #4
    Senior Coder DanInMa's Avatar
    Join Date
    Nov 2010
    Location
    Salem,Ma
    Posts
    1,577
    Thanks
    13
    Thanked 248 Times in 248 Posts
    sweet. yep looks liek you jsut forgot to add the intial <tr> for each row in your record loop

  • #5
    Regular Coder
    Join Date
    Nov 2005
    Posts
    750
    Thanks
    138
    Thanked 1 Time in 1 Post
    Thanks again!

  • #6
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,588
    Thanks
    80
    Thanked 4,497 Times in 4,461 Posts
    This is clearly bogus:
    Code:
    		<td >Dispatched</td></font>
    (a) You have no matching <font> tag.
    (b) Even if you did, the <font>...</font> pair should be *INSIDE* one of your <td>...</td> pairs.
    (c) And even at that the <font> tag is deprecated; you should be setting a style, instead.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #7
    Regular Coder
    Join Date
    Nov 2005
    Posts
    750
    Thanks
    138
    Thanked 1 Time in 1 Post
    Thank you for that Old Pedant

    I have removed <font> and tidied up a couple of other things at the same time. Sometimes I unconsciously revert to the older style, but things are looking better.

    I still get a couple of HTML errors so I will try to resolve them.

    Thanks again!

    Steve

  • #8
    Senior Coder DanInMa's Avatar
    Join Date
    Nov 2010
    Location
    Salem,Ma
    Posts
    1,577
    Thanks
    13
    Thanked 248 Times in 248 Posts
    feel free to repost I can probably help you sort them out

  • #9
    Regular Coder
    Join Date
    Nov 2005
    Posts
    750
    Thanks
    138
    Thanked 1 Time in 1 Post
    Hello DanInMa

    Many thanks.

    I have a 'test' site here:

    http://www.bayingwolf.com/display_recordsTEST.asp

    If you click on 'Add Records' at the bottom, a form pops up. When the fields are completed, I am hoping that the new record will be added to the
    database.

    I have an 'Add Records' script that works:

    http://www.bayingwolf.com/addRecords1.asp

    What I need to do is add that script to the display_recordsTEST.asp file. I am not asking you to do it, but if you could give me some guidelines as to where to start, that would be helpful.

    This is the addRecords1.asp code:

    Code:
    <% 
    'declare your variables
    
    Dim conn, rs, sSQL, sConnString, my_firstName, my_lastName, my_wolfID, my_telNo, my_stAddress, my_city, my_postCode, my_items, my_received, my_dispatched
    
    my_firstName = Replace( Request.Form("firstName"), "'", "''" )
    my_lastName = Replace( Request.Form("lastName"), "'", "''" )
    my_wolfID = CDBL( Request.Form("wolfID") )
    my_telNo = CDBL( Request.Form("telNo") )
    my_stAddress = Replace( Request.Form("stAddress"), "'", "''" )
    my_city = Replace( Request.Form("city"), "'", "''" )
    my_postCode = Replace( Request.Form("postCode"), "'", "''" )
    my_items = Replace( Request.Form("items"), "'", "''" )
    my_received = CDATE( Request.Form("received") )
    my_dispatched = CDATE( Request.Form("dispatched") )
    
    
    sSQL="INSERT INTO tblWolf " _
         & "(firstName, lastName, wolfID, telNo, stAddress, city, postCode, items, received, dispatched)" _
         & "  VALUES ('" & my_firstName & "', '" & my_lastName & "'," & my_wolfID & ", " _
         & my_telNo & ", '" & my_stAddress & "', '" & my_city & "', '" & my_postCode & "'," _
         & " '" & my_items & "', #" & my_received & "#, #" & my_dispatched & "#)"
    
    Set connection = Server.CreateObject("ADODB.Connection")
     Set recordset = Server.CreateObject("ADODB.Recordset")
    
    
    sConnString="PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _ 
    "Data Source=" & "E:\Domains\bayingwolf.com\clients.mdb"
    
    'Open the connection to the database
     connection.Open sConnString
    
    connection.Execute sSQL
    
    Response.write "<div align='center'><br>The record has been added.</div>"
    
    
    'close the connection and recordset objects and free up resources
    
     connection.Close
     
     Set connection = Nothing
    %>
    Many thanks for any help.

    Steve

  • #10
    Senior Coder DanInMa's Avatar
    Join Date
    Nov 2010
    Location
    Salem,Ma
    Posts
    1,577
    Thanks
    13
    Thanked 248 Times in 248 Posts
    well, since you are already using jQuery for the modal , Im guessing that you also want to submit the data while avoiding a page refresh? First program the popup form to work by submitting it's data to addrecords1.asp . once you have that working, then you can leverage jQuery to do it without a page refresh. here is a basic example

    Code:
    $("#idOfMyForm").submit(function(e) {
    e.preventDefault(); // prevent page refresh
    var myData = $(this).serialize(); // turns all form values into a querystring
      $.ajax({
        type: "POST",
        url: "addrecords1.asp",
        data: myData ,
        success: function() {
    //do stuff here like show a window stating Record submitted!, then close your modal window
    //this is also where you can add some code to update the table shown on the page while avodiing page refresh
        }
      });
    
    
    })

  • Users who have thanked DanInMa for this post:

    SteveH (09-14-2013)

  • #11
    Regular Coder
    Join Date
    Nov 2005
    Posts
    750
    Thanks
    138
    Thanked 1 Time in 1 Post
    Hello DanInMa

    Wow! That was quick! Thank you.

    I will need to digest this, so first things first. So, instead of the following which I have in display_recordsTEST.asp

    Code:
    <div id="basic-modal-content">
    
    <form action="display_recordsTEST.asp" method="post">
    
    <h3>Add records</h3>
    
    <p>Complete each form field to add records to the MS Access database.</p>
    
    <p>First Name:</p>
    <p><input type="text" name="firstName" id="firstName" /></p>
    
    <p>Surname:</p>
    <p><input type="text" name="lastName" id="lastName" /></p>
    
    <p>Wolf ID:</p>
    <p><input type="text" name="wolfID" id="wolfID" /></p>
    
    <p>Tel No:</p>
    <p><input type="text" name="telNo" id="telNo" /></p>
    
    <p>Address:</p>
    <p><input type="text" name="stAddress" id="stAddress" /></p>
    
    <p>City:</p>
    <p><input type="text" name="city" id="city" /></p>
    
    <p>Postcode:</p>
    <p><input type="text" name="postCode" id="postCode" /></p>
    
    <p>Items:</p>
    <p><input type="text" name="items" id="items" /></p>
    
    <p>Date received:</p>
    <p><input type="text" name="received" id="received" /></p>
    
    <p>Date dispatched:</p>
    <p><input type="text" name="dispatched" id="dispatched" /></p>
    <p class="submit"><input type="submit" value="Add data" /></p>
    </form>
    
    </div>
    I use this:

    Code:
    <form action="addRecords1.asp" method="post">
    
    Thanks again

  • #12
    Senior Coder DanInMa's Avatar
    Join Date
    Nov 2010
    Location
    Salem,Ma
    Posts
    1,577
    Thanks
    13
    Thanked 248 Times in 248 Posts
    to make it work the "normal" way? yes. If you make that oen change, once you click on the button, you should then be forwarded to the addrecords page and get the record added message if you put one in there. ( currently addrecords1.asp will process without any data and return the record added response, but I doubt it's adding a blank record so you probabaly need some help working that out too - in the asp forum of course) Take baby steps, get the form working the regular way ( you can technically skip this part but then your form doesnt work for peopel that have javascript disabled) , then you can start fudging with the jQuery code i provided, in order to submit the data via ajax to avoid a page refresh and being directed to the addrecords1.asp.

    once you get that far, then you can get some help updating your table view on the dis-play page also using an ajax call. ( baby steps , trust me)

  • Users who have thanked DanInMa for this post:

    SteveH (09-14-2013)

  • #13
    Regular Coder
    Join Date
    Nov 2005
    Posts
    750
    Thanks
    138
    Thanked 1 Time in 1 Post
    Hello DanInMa

    That sounds like good advice.

    Over the next couple of days I will hopefully get the script to work in the normal way and then refer back to the JQuery you kindly provided.

    If I have an issue or doubt, you may find me back here mid-week!

    Very many thanks again for all your patience and time.

    Much appreciated.

    Steve


  •  

    Posting Permissions

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