Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding detailed results from search in asp 1

Status
Not open for further replies.

nissan240zx

Programmer
Jun 26, 2005
280
0
0
US
Hello DNG,
couple of questions.
Now that we have list of records getting displayed based on selection from the list box.
How do you select a specific record from the search results and show it in detail.
I know we can use hyperlinks to make the search results active but do we use query strings to move the field values from search_results.asp to say search_specific.asp

Also wanted to know can the list box section have muliple values.
For example if anyone wants to search by product category and product price.
How does that work. if I have 100 items in price range of $50 to $1000 and if I want to show in my list box select price range; $50 - $100, $100 - 500, 500 and above.

Please advice....

Thank a million in advance

Nissan 240 ZX...best Nissan Ever
 
here you go:

Code:
<html>
<body>
<%
'declare variables
dim rs, conn, sql, userselection

'grab user selected item from the dropdown
userselection=request.form("mydropbox")

'set all our objects
set rs=server.createobject("adodb.recordset")
set conn=server.createobject("adodb.connection")

'open connection string
conn.open "your connectionstring here"
'write our sql statement
sql = "your sql string here"
'here is a sample sql of how it should look

'sql="SELECT * FROM table2 WHERE myfield='"&userselection&"';"


rs.open sql, conn

IF rs.EOF AND rs.BOF then
response.write "sorry, no records found"
else
%> 

<table border="1", cellspacing="1", cellpadding="1">
<tr>
 
[red][b]<th>Click Here</th>[/b][/red]
<th>Product ID</th>
<th>Product Name</th>
<th>Description</th>
<th>Vendor Name</th>
<th>Contact Information</th>

<% 
do until rs.EOF
%> 
<tr>
[red][b]<td align="center"><font size="2" face="verdana"><a href= "#" ONCLICK = 'ViewDetail("<%=rs("ProductId")%>")'>Details</a></td>[/b][/red]
<td align="center"><font size="2" face="verdana"><%=rs("ProductId")%></td>
<td align="center"><font size="2" face="verdana"><%=rs("ProductName")%></td>
<td align="center"><font size="2" face="verdana"><%=rs("ProductDesc")%></td>
<td align="center"><font size="2" face="verdana"><%=rs("VendorName")%></td>
<td align="center"><font size="2" face="verdana"><%=rs("ContactInfo")%></td>
<%
rs.movenext
loop

    End If
rs.close
set rs=nothing
con.close
set con=nothing

%>
</table>
[red][b]
<script language="VBscript">
Sub ViewDetail(ProductId)
Window.Open "search_specific.asp?ProductId="&ProductId
End Sub
</script>[/b][/red]
</body>

</html>


now on search_specific.asp page, you do the following...

[code]
<%
prodId=request.querystring("ProductId")


set rs=server.createobject("adodb.recordset")
set conn=server.createobject("adodb.connection")


conn.open "your connectionstring here"


sql="SELECT * FROM Products WHERE ProductId="&prodId

rs.open sql, conn

'Now go ahead and display the product details in
'whatever way you want...i mean either in table format
'or anyother format...

%>

Hope this helps...post back if you have questions...

-DNG
 
first lets solve the first question and then we can move on with the second question...actually i did not understand your second questions completely...may be we can discuss about that after we are done with the first one...

post back if you have any questions...

-DNG
 
alright..I will test this and give you updates..
Thanks in advance...

Are you from the US..?

Nissan 240 ZX...best Nissan Ever
 
Hello DNG,
Everything looks wonderful. No problems at all.
One question:
Here instead of opening specific results in a new window, can it be shown in the same browser window..
These days with all these popup blockers..this might not be a good process..
Code:
<script language="VBscript">
Sub ViewDetail(ProductId)
Window.Open "search_specific.asp?ProductId="&ProductId
End Sub
</script>

I am also from the US..Atlanta, GA to be specific..




Nissan 240 ZX...best Nissan Ever
 
Whenever you are ready I can post the second question as a new post.
Just let me know..

Nissan 240 ZX...best Nissan Ever
 
if you want to open in the same browser then change this line

Window.Open "search_specific.asp?ProductId="&ProductId

to

window.location= "search_specific.asp?ProductId="&ProductId

after you are done with first problem...go ahead and post the second question again...

i hope you are learning something instead of just blindly copying my code...


-DNG
 
Hello DNG,
I am doing lot more than blindly doing cut/copy/paste.
I am improvising the code and adding some elements of my own.
Once the whole thing is complete I will show you the live url.
I am going to post the second question now..

Nissan 240 ZX...best Nissan Ever
 
i am glad to hear that...so where is my part of the pay for assisting you...just kidding...

good luck...

-DNG
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top