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 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Feb 2012
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Help With Concatenation

    I've been asked to make our internal telephone directory more 'intelligent'.

    To do this I've added an extra field to the existing directory database and called it URL. This will effectively list a person's entry by their team.

    I now need some help with the markup.

    This line works;
    Response.write("<TD class=helpbod><A Href=http://ksprod/ks/helper/3164.asp?selected=31>")
    However it generates a static URL that only shows entries in the list that relate to the team members who have an entry of 31 in the Team field.

    How do I make this code dynamic?

    Here's the original search routine;
    Code:
    do until rs.EOF
    a = rs.fields.item("postalsector")
    b = rs.fields.item("MeterReadingTeam")
    c = rs.fields.item("subareaname")
    d = rs.fields.item("Depot")
    Response.write("<TD class=helpbod style='width: 50pt;'>")
    Response.Write(A)
    Response.write("<TD class=helpbod>")
    Response.Write(B) 
    Response.write("<TD class=helpbod><A Href=http://ksprod/ks/helper/3164.asp?selected=31>")
    Response.Write(C) & "</A>" 
    Response.write("<TD class=helpbod style='width: 50pt;'>")
    Response.Write(D)
    Response.Write("<TR>")
    rs.MoveNext
    loop
    
    rs.close
    conn.close
    
    Here's the new routine that doesn't work;
    <TABLE CLASS=MeterR>
    <td class=helphed style='width: 50pt;'>Post Code</td >
    <td class=helphed>Reading Team</td></td>
    <td class=helphed>Locality</td>
    <td class=helphed>Depot</td>
    <td class=helphed>URL</td></tr>
    <tr>
    <%
    searchc=request.form("searchc")
    postc=request.form("postc")
    
    
    
    set conn=Server.CreateObject("ADODB.Connection")
    conn.Provider="Microsoft.Jet.OLEDB.4.0"
    conn.Open "d:\knowledge solutions\publish\2232.mdb"
    set rs = Server.CreateObject("ADODB.recordset")
    
    rs.Open "SELECT * FROM MeterReaders where " & searchc & " like '" & postc & "%'", conn
    
    
    do until rs.EOF
    a = rs.fields.item("postalsector")
    b = rs.fields.item("MeterReadingTeam")
    c = rs.fields.item("subareaname")
    d = rs.fields.item("Depot")
    e = rs.fields.item("URL")
    Response.write("<TD class=helpbod style='width: 50pt;'>")
    Response.Write(A)
    Response.write("<TD class=helpbod>")
    Response.Write(B) 
    Response.write("<TD class=helpbod><A Href=http://ksprod/ks/helper/3164.asp?selected=<%rs1.fields.item("URL")%>>")
    Response.Write(C) & "</A>" 
    Response.write("<TD class=helpbod style='width: 50pt;'>")
    Response.Write(D)
    Response.write("<TD class=helpbod style='width: 50pt;'>")
    Response.Write(E)
    Response.Write("<TR>")
    rs.MoveNext
    loop
    
    rs.close
    conn.close
    Last edited by VIPStephan; 02-24-2012 at 11:17 PM. Reason: wrapped code BB tags

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,596
    Thanks
    80
    Thanked 4,633 Times in 4,595 Posts
    You can't ember <%...%> tags inside of already existing <%...%> tags.

    So this line:
    Code:
    Response.write("<TD class=helpbod><A Href=http://ksprod/ks/helper/3164.asp?selected=<%rs1.fields.item("URL")%>>")
    must be changed.

    But your HTML isn't even close to legal. You don't have any </tr> to mark the end of a row or </td> to mark the end of a cell.
    And you aren't using "..." around all attribute values. Your HTML surely would *NOT* validate.

    Personally, I would have done the whole schmear like this:
    Code:
    do until rs.EOF
    %>
    <tr>
        <td class="helpbod" style="width: 50pt;"><%=rs("postalselector")%></td>
        <td class="helpbod"><%=rs("MeterReadingTeam")%></td>
        <td class="helpbod"><a href="http://ksprod/ks/helper/3164.asp?selected=<%rs1("URL")%>"></a></td>
        <td class="helpbod" style="width: 50pt;"><%=rs("depot")%></td>
        <td class="helpbod" style="width: 50pt;"><%=rs("URL")%></td>
    </tr>
    <%
        rs.MoveNext
    loop
    ...
    But if you insist on using Response.Write (which is harder to write, harder to read, and a bit slower...not to mention easier to miss things like needed </td>s and </tr>s... then:
    Code:
    Response.Write "<td class=""helpbod""><a Href=""http://ksprod/ks/helper/3164.asp?selected=" & rs1("URL") & """></a></td>"
    Technically, you should *NOT* use ( ) after Response.Write.

    And using rs1.field.item("URL") works but is slower and more to write than simply rs1("URL") which does exactly the same thing.
    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.

  • Users who have thanked Old Pedant for this post:

    BorderTerroir (03-01-2012)

  • #3
    New to the CF scene
    Join Date
    Feb 2012
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thanks for the reply OP.

    The whole of the coding and the myriad of MS Access databses is something I inherited when the guy who created it left the company.

    There is no documentation, I'm finding problems all the time.

    John

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,596
    Thanks
    80
    Thanked 4,633 Times in 4,595 Posts
    Well, despite you having problems now, maybe it was good he left if he wrote code like that.
    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.


  •  

    Posting Permissions

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