p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

proasp_howto thread: Detail buttons to access records in Database


Message #1 by ed@e... on Tue, 13 Aug 2002 14:24:42
I am listing a database in a table along with a 'Details' button.
When I click on a given 'Details' button I need it to tell me the 
record number that I clicked on. My problem I think is how to setup the 
onclick event.
Can anyone help me?
Here is code I am debugging:

sub cmd_SetKey(CKey)
     request.form("CKey")=CKey
end sub
.
.
.
strSQL="select count(*) AS RecCnt from Master"
set objRS =objConn.Execute(strSQL,intRecsAffected)
intRC=cint(objRS("RecCnt"))
strSQL="select * from Master Order by Year,SchoolLastName"
set objRS =objConn.Execute(strSQL,intRecsAffected)
If intRC>0 Then
	response.Write("<FORM ID=frmEntry name=frmEntry 
action=responsc.asp method=post>")
	response.Write("<table border=1>")
	Do while not objRS.EOF
	if len(trim(objRS("LastName")))>0 then Nam=objRS("FirstName") 
& "(" & objRS("SchoolLastName") & ")" & objRS("LastName") else Nam=objRS
("FirstName") & " " & objRS("SchoolLastName")
	select case "Y"
	case objRS("EmailH_YN"):DEmail=objRS("HomeEmail")		
	case objRS("EmailW_YN"):DEmail=objRS("WorkEmail")
	case objRS("EmailO_YN"):DEmail=objRS("OtherEmail")
	case else DEmail=""
	end select
	response.Write("<tr><td>" & objRS("IDNo") & "</td><td>" & Nam 
& "</td><td><a href=mailto:" & DEmail & ">" & DEmail 
& "</a></td><td><Input name=cmd value=Details type=submit 
onclick=""cmd_SetKey(" & objRS("IDNo") & ")""></td></tr>") 	
	objRS.MoveNext
	Loop
response.Write("</table><br>")
if session("ctype")="A" then
	response.Write("<center><p>Num: <input id=txtNum name=txtNum 
type=text style=left: 119px; top: 69px size=9>&nbsp;&nbsp;")
	response.Write("<input name=ckey type=hidden value=1>")
	response.Write("<input id=cmd name=cmd type=SUBMIT 
value=Edit>&nbsp;&nbsp;")
	response.Write("<input id=cmd name=cmd type=SUBMIT 
value=Add>&nbsp;&nbsp;")
	response.Write("<input id=cmd name=cmd type=SUBMIT 
value=More>&nbsp;&nbsp;")
	response.Write("<input id=cmd name=cmd type=SUBMIT 
value=Money>&nbsp;&nbsp;")
	response.Write("<input id=cmd name=cmd type=SUBMIT value=Email>")
	response.Write("<br>Count= " & intRC & "&nbsp;&nbsp;Hits=" & 
Class62PH.Hits & "</p></center></FORM>")
else
	response.Write("<center><input id=cmd name=cmd type=SUBMIT 
value=More>&nbsp;&nbsp;")
	response.Write("Count= " & intRC & "</p></center></FORM>")
end if
Else
	response.redirect "Ostuff.htm"	
end If
.
.
.
strSQL="select * from Master where IDNo=" & Request.form("Ckey")
set objRS =objConn.Execute(strSQL,intRecsAffected)
if len(trim(objRS("LastName")))>0 then Nam=objRS("FirstName") & "(" & objRS
("SchoolLastName") & ")" & objRS("LastName") else Nam=objRS("FirstName") 
& " " & objRS("SchoolLastName")
if len(objRS("Paid"))>0 then paidAmt=csng(objRS("Paid")) else paidAmt=0
response.Write("<table border=1>")
response.Write("<tr><td>" & objRS("IDNo") & "</td><td>" & Nam 
& "</td></tr>")
response.Write("</table><br><br>")
response.Write("<FORM ID=frmEntry name=frmEntry action=responsc.asp 
method=post>")
response.Write("<center><input id=cmd name=cmd type=SUBMIT value=List>")
response.Write("</p></center></FORM>")

ed@e...

  Return to Index