...

View Full Version : link from response.write



needhelp26
07-15-2004, 03:09 AM
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.

glenngv
07-15-2004, 05:56 AM
This?

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

angst
07-15-2004, 03:41 PM
or just
<%="<td><a href=""page.asp?id=" & RS ("id") & """>" & RS ("name") & "</a></td>"%>

glenngv
07-16-2004, 03:33 AM
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.

needhelp26
07-16-2004, 04:21 AM
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.

glenngv
07-16-2004, 06:18 AM
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.

needhelp26
07-16-2004, 01:04 PM
Thankyou.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum