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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Select from HTML Table to Isolate Record? 1

Status
Not open for further replies.

Caper

Technical User
Aug 11, 2001
9
US
I'm using ADO to populate a "SELECT" form, which pulls a unique list of people from an Access DB. Once the user selects a name from the list I produce an HTML table from all the tblJobs records that have that name (see code below). This works very well, but now I want the user to be able to click on one of the table rows (select a specific job) and produce a new table of all the reports produced as a result of that job, posted to a new HTML page floating on top of the original. I assume this task hinges on setting an identifying variable based on the specific job, and then passing that variable to the new page which uses it to requery the DB to build the new table - but that's where I run up against my own ignorance. Can anyone help? Thanks in advance...!

Code:
<%
dim ConnString
dim Conn
dim rs

ConnString = &quot;DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=&quot; & Server.MapPath(&quot;GAS.mdb&quot;)
Set conn = Server.CreateObject(&quot;ADODB.Connection&quot;)
conn.Open ConnString
Set rs = SERVER.CreateObject(&quot;ADODB.Recordset&quot;)
' first have to get the category records to fill the drop down....
' Set SQL statement
strSQL = &quot;SELECT DISTINCT tblJobs.Owner FROM tblJobs ORDER BY tblJobs.Owner;&quot;
	
' Open Recordset Object
rs.Open strSQL,conn, adOpenStatic
%>

<html>
<body bgcolor=&quot;black&quot; text=&quot;gold&quot; link=&quot;gold&quot; vlink=&quot;gold&quot;>

<FORM name=&quot;formCategory&quot;> 
<SELECT NAME=&quot;qryCategory&quot; onChange=&quot;getFilter(this.form.qryCategory)&quot;>
<OPTION selected>Select A Job Owner:
<% Do While Not rs.EOF
	Response.Write (&quot;<OPTION value='&quot; & rs(&quot;Owner&quot;) & &quot;'>&quot; & rs(&quot;Owner&quot;))
	rs.MoveNext
Loop
rs.Close
Set rs=Nothing
%>  	
</OPTION> 
</SELECT><BR>
</FORM>

<SCRIPT language=&quot;JavaScript&quot;>

function getFilter(listitem){
	var object = &quot;&quot;;
	var listValue = getListValue(listitem);
	
	document.formCategory.submit(listValue);
	
}


function getListValue(list){
	var listValue=&quot;&quot;;
	if (list.selectedIndex != -1) {
		listValue = list.options[list.selectedIndex].value;
		}
	return (listValue);
}

</SCRIPT>

<% 

dim arrArray()
dim i
i=0

If Request.QueryString(&quot;qryCategory&quot;) = &quot;&quot; Then
	Response.Write(&quot;Please select a Job Owner from the list.&quot;)
Else
	' Build query
	Set rs = SERVER.CreateObject(&quot;ADODB.Recordset&quot;)
	' first have to get the category records to fill the drop down....
	' Set SQL statement
	'strSQL = &quot;SELECT Uploads.Employee_Name, Uploads.File_Type, Uploads.Upload_File_Name, Uploads.Date_Submitted, &quot;
	'strSQL = strSQL & &quot;Uploads.Comments, Uploads.Employee_Email, Uploads.Subject_Line, Upload_Category.Category_Name &quot;
	'strSQL = strSQL & &quot;FROM Upload_Category INNER JOIN Uploads ON Upload_Category.Category_Id = Uploads.Category_Id &quot;
	'strSQL = strSQL & &quot;WHERE (((Upload_Category.Category_Name) = '&quot; & Request.QueryString(&quot;qryCategory&quot;) & &quot;'))&quot;

	strSQL = &quot;SELECT * FROM tblJobs WHERE (((tblJobs.Owner) = '&quot; & Request.QueryString(&quot;qryCategory&quot;) & &quot;')) ORDER BY tblJobs.job_id DESC&quot;
	
	' Open Recordset Object
	rs.Open strSQL,conn,adOpenStatic

	If rs.RecordCount = 0 Then
		Response.Write(&quot;No records found for Job Owner: &quot; & Request.QueryString(&quot;qryCategory&quot;))
	Else
		Response.Write(&quot;<H3>Items Found for Job Owner: &quot; & Request.QueryString(&quot;qryCategory&quot;) & &quot;</H3>&quot;)
	
	' Build a table here
	Response.Write(&quot;<TABLE CELLSPACING=2 CELLPADDING=0 COLS=3 WIDTH=500 BGCOLOR=Black>&quot;)
	Response.Write(&quot;<TR>&quot;)
	Response.Write(&quot;<TD ALIGN=CENTER VALIGN=TOP WIDTH=30% BGCOLOR=Blue><B>Name</B></TD>&quot;)
	Response.Write(&quot;<TD ALIGN=CENTER VALIGN=TOP WIDTH=40% BGCOLOR=Blue><B>Project</B></TD>&quot;)
	Response.Write(&quot;<TD ALIGN=CENTER VALIGN=TOP WIDTH=15% BGCOLOR=Blue><B>WBS</B></TD>&quot;)
	Response.Write(&quot;<TD ALIGN=CENTER VALIGN=TOP WIDTH=15% BGCOLOR=Blue><B>Job #</B></TD>&quot;)
	Response.Write(&quot;</TR>&quot;)
		
	Do While Not rs.EOF
		'the anchor javascript opens a new window with various controllable parameters - very handy!
		Response.Write(&quot;<TR></tr><a href=&quot;&quot;javascript:void(0);&quot;&quot; onclick=&quot;&quot;window.open('[URL unfurl="true"]http://scotts-pc/test.htm',[/URL] 'Window1', 'location=no, menubar=no, height=300, width=400, status=no, resizable=no, scrollbar ')&quot;&quot;>&quot;)
		Response.Write(&quot;<TD><u>&quot; & rs(&quot;Owner&quot;) & &quot;</u></TD>&quot;)
		Response.Write(&quot;<TD><u>&quot; & rs(&quot;Project&quot;) & &quot;</u></TD>&quot;)
		Response.Write(&quot;<TD><u>&quot; & rs(&quot;WBS&quot;) & &quot;</u></TD>&quot;)
		Response.Write(&quot;<TD><u>&quot; & rs(&quot;job_id&quot;) & &quot;</u></TD>&quot;)
		Response.Write(&quot;</a></TR>&quot;)
		rs.MoveNext
	Loop
			
	rs.Close
	
	Response.Write(&quot;</TABLE>&quot;)
	
	End If
	
End If

Set rs=Nothing

conn.Close
Set conn=Nothing

%> 

</body>
</html>
 
Hi!

In your URL, add the parameters you'll need for the next page, like:

Code:
Response.Write(&quot;<TR></tr><a href=&quot;&quot;javascript:void(0);&quot;&quot; onclick=&quot;&quot;window.open('[URL unfurl="true"]http://scotts-pc/test.htm?ownerid=&quot;[/URL] & rs(&quot;Owner&quot;) & &quot;&jobid=&quot; & rs(&quot;job_id&quot;) & &quot;', 'Window1', 'location=no, menubar=no, height=300, width=400, status=no, resizable=no, scrollbar ')&quot;&quot;>&quot;)
Then in the new page:
Code:
dim ownerid, jobid
ownerid = request.querystring(&quot;ownerid&quot;)
jobid = request.querystring(&quot;jobid&quot;)
Hope this helps! Jessica [ponytails2]
 
BTW your you have an extra </tr> in there, so use this instead:
Code:
Response.Write(&quot;<TR><a href=&quot;&quot;javascript:void(0);&quot;&quot; onclick=&quot;&quot;window.open('[URL unfurl="true"]http://scotts-pc/test.htm?ownerid=&quot;[/URL] & rs(&quot;Owner&quot;) & &quot;&jobid=&quot; & rs(&quot;job_id&quot;) & &quot;', 'Window1', 'location=no, menubar=no, height=300, width=400, status=no, resizable=no, scrollbar ')&quot;&quot;>&quot;)
Jessica [ponytails2]
 
Thanks Jessica, that's exactly what I needed! It works perfectly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top