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 7 of 7
  1. #1
    Regular Coder
    Join Date
    Jul 2004
    Posts
    101
    Thanks
    0
    Thanked 0 Times in 0 Posts

    link from response.write

    Can someone please give the syntax for the following code:

    <% Response.write "<td>" & RS ("name") & "</td>"%>

    Now, I want to add a link to the name field, so in the display page, when clicked on name field, should linked to another page based on table id field.

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,946
    Thanks
    0
    Thanked 236 Times in 233 Posts
    This?

    <%
    Response.write "<td><a href=""page.asp?id=" & RS ("id") & """>" & RS ("name") & "</a></td>"
    %>

  • #3
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    or just
    <%="<td><a href=""page.asp?id=" & RS ("id") & """>" & RS ("name") & "</a></td>"%>

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,946
    Thanks
    0
    Thanked 236 Times in 233 Posts
    Or:

    <td><a href="page.asp?id=<%=RS ("id")%>"><%=RS ("name")%></a></td>

    It really depends on how the codes before and after it are formatted.

  • #5
    Regular Coder
    Join Date
    Jul 2004
    Posts
    101
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The linked worked well. But I am having another problem. The id from the first form is not passing to the next, not in the link specified.
    Let me explain my program:

    This is a search page where on the search result page when click on name, that field should be linked to another page with detailed info of that particular name.

    First page:
    dim con,rs, sql

    sql = "Select * from Mytable where loc = '" & loc & "'"

    Set conn = server.createobject("adodb.connection")
    conn.open "dsn"

    Set Rs = server.createobject("adodb.connection")
    Set RS = con.execute(sql)
    Response.Write "<center><table border=""0"" width='50%'>"

    Response.write"<tr bgcolor=silver >"
    Response.write "<td ><a href=""page.asp?id = " & RS ("id") & """>" & RS("name") & "</td>"
    Response.write"<td >" & RS("loc") & "</td>"
    Response.write"<td >" & RS("dept") & "</td>"
    Response.write"</tr>"



    RS.Movenext

    Loop
    RS.Close
    Response.write "</table>"
    End If
    MyConn.Close
    Set RS = Nothing
    Set MyConn = Nothing
    %>

    ---------------

    Second page:
    <%
    id = Request.form("id")

    sql1= "Select * from Mytable where [id] = "& id
    database connection

    While Not RS.EOF
    <table>
    <tr>
    <td>Occupation</td>
    <td><%=rs("Occpt")%></td>
    <td>Sal</td>
    <td><%=rs("sal")%></td>
    <td>dept</td>
    <td><%=rs("dept")%></td>
    </tr>
    </table>

    RS.Movenext
    Wend

    RS.Close
    Set RS=nothing
    Conn.close
    Set conn=nothing

    %>

    Since was getting an error, did response.write for request.form (id), the id is not passing to the second page, it says just 'id'. Can someone look at my code, and fix my problem. But when i look at the address bar, id no is displayed but when response.write the id, it is not passing.

  • #6
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,946
    Thanks
    0
    Thanked 236 Times in 233 Posts
    Since you are passing the data in the URL (GET), you need to use Request.Querystring instead of Request.Form.

    id = Request.Querystring("id")

    Request.Form is only used if the form is submitted via POST.

  • #7
    Regular Coder
    Join Date
    Jul 2004
    Posts
    101
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thankyou.


  •  

    Posting Permissions

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