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

how to create button to delete record?

Status
Not open for further replies.

BEJW

Programmer
Mar 25, 2003
13
US
Thanks All.

JW
 
DELETE FROM table_name
WHERE column_name = some_value

Your Welcome

if you need any more help can you give up a little more detailed explanation on what you are doing and what the situation is?

____________________________________________________
get the best answer to your questions by asking the best questions "General FAQ" faq333-2924
onpnt2.gif
 
Thanks onpnt.

The following are my codes. I try to delete, add new..., but I don't know how to get them. Thanks again

JW


*******************

<HTML>
<HEAD>
<TITLE> CLINICAL DATABASE</TITLE>
</HEAD>
<BODY>

<CENTER>

<H1><FONT size=8>Clinical Database</H1></FONT>


<%=FormatDateTime(Now(),1) %>

<%

dim myconnection
dim rsPatientInfo
dim connectString
dim sqlString
dim requestPatientID

connectString = &quot;Provider=Microsoft.Jet.OLEDB.4.0;&quot; _
& &quot;Data Source=C:\Inetpub\
set myConnection = Server.CreateObject(&quot;ADODB.Connection&quot;)
set rsPatientInfo = Server.CreateObject(&quot;ADODB.Recordset&quot;)

myConnection.Open connectString
requestPatientID = Request.Form(&quot;PatientID&quot;)

if (cstr(requestPatientID) = &quot;&quot;) then
Response.write(&quot;Request ID is required. &quot;)
else
sqlString = &quot;select * from Patients, Examinations where Patients.PatientID = Examinations.ID and PatientID = &quot; & requestPatientID
Set rsPatientInfo = myConnection.Execute(sqlString)

If(rsPatientInfo.BOF) AND (rsPatientInfo.EOF) then
Response.write(&quot;Sorry, but Patient's ID &quot; & requestPatientID _
& &quot; was not found.&quot;)
ELSE
%>

<TABLE align=center COLSPAN=30 CELLPADDING=3 BORDER=0 WIDTH = 300>
<!-- Begin column header row -->

<TR>
<TD VALIGN=TOP BGCOLOR=#800000&quot;>

<FONT STYLE+&quot;ARIAL NARROW&quot; COLOR=&quot;#ffffff&quot; size=2>

PatientID
</FONT>
</TD>
<TD ALIGN=CENTER BGCOLOR=#800000&quot;>
<FONT STYLE+&quot;ARIAL NARROW&quot; COLOR=&quot;#ffffff&quot; size=2>

First Name
</FONT>
</TD>

<TD ALIGN=CENTER BGCOLOR=#800000&quot;>
<FONT STYLE+&quot;ARIAL NARROW&quot; COLOR=&quot;#ffffff&quot; size=2>

Last Name
</FONT>
</TD>

<TD ALIGN=CENTER BGCOLOR=#800000&quot;>
<FONT STYLE+&quot;ARIAL NARROW&quot; COLOR=&quot;#ffffff&quot; size=2>

DOB
</FONT>
</TD>

<TD ALIGN=CENTER BGCOLOR=#800000&quot;>
<FONT STYLE+&quot;ARIAL NARROW&quot; COLOR=&quot;#ffffff&quot; size=2>

Education
</FONT>
</TD>

<TD ALIGN=CENTER BGCOLOR=#800000&quot;>
<FONT STYLE+&quot;ARIAL NARROW&quot; COLOR=&quot;#ffffff&quot; size=2>

Diagnosis
</FONT>
</TD>

<TD ALIGN=CENTER BGCOLOR=#800000&quot;>
<FONT STYLE+&quot;ARIAL NARROW&quot; COLOR=&quot;#ffffff&quot; size=2>

Diagnostic Code
</FONT>
</TD>


<TD ALIGN=CENTER BGCOLOR=#800000&quot;>
<FONT STYLE+&quot;ARIAL NARROW&quot; COLOR=&quot;#ffffff&quot; size=2>

SH
</FONT>
</TD>

<TD ALIGN=CENTER BGCOLOR=#800000&quot;>
<FONT STYLE+&quot;ARIAL NARROW&quot; COLOR=&quot;#ffffff&quot; size=2>

FrSBE Total
</FONT>
</TD>

<TD ALIGN=CENTER BGCOLOR=#800000&quot;>
<FONT STYLE+&quot;ARIAL NARROW&quot; COLOR=&quot;#ffffff&quot; size=2>

DRS total
</FONT>
</TD>

<TD ALIGN=CENTER BGCOLOR=#800000&quot;>
<FONT STYLE+&quot;ARIAL NARROW&quot; COLOR=&quot;#ffffff&quot; size=2>

MMSE Score
</FONT>
</TD>

<TD ALIGN=CENTER BGCOLOR=#800000&quot;>
<FONT STYLE+&quot;ARIAL NARROW&quot; COLOR=&quot;#ffffff&quot; size=2>

APeE Genetype
</FONT>
</TD>


<TD ALIGN=CENTER BGCOLOR=#800000&quot;>
<FONT STYLE+&quot;ARIAL NARROW&quot; COLOR=&quot;#ffffff&quot; size=2>

Date Of Evaluation
</FONT>
</TD>
</TR>

<!-- Get Data -->

<% do while not rsPatientInfo.EOF %>
<TR>

<TD BGcolor =&quot;f7efde&quot; align=center>
<font style = &quot;arial narrow&quot; size=2>
<%=rsPatientInfo(&quot;PatientID&quot;)%>
</font>
</TD>

<TD BGcolor =&quot;f7efde&quot; align=center>
<font style = &quot;arial narrow&quot; size=2>
<%=rsPatientInfo(&quot;First Name&quot;)%>
</font>
</TD>


<TD BGcolor =&quot;f7efde&quot; align=center>
<font style = &quot;arial narrow&quot; size=2>
<%=rsPatientInfo(&quot;Last Name&quot;)%>
</font>
</TD>


<TD BGcolor =&quot;f7efde&quot; align=center>
<font style = &quot;arial narrow&quot; size=2>
<%=rsPatientInfo(&quot;DOB&quot;)%>
</font>
</TD>


<TD BGcolor =&quot;f7efde&quot; align=center>
<font style = &quot;arial narrow&quot; size=2>
<%=rsPatientInfo(&quot;Education&quot;)%>
</font>
</TD>



<TD BGcolor =&quot;f7efde&quot; align=center>
<font style = &quot;arial narrow&quot; size=2>
<%=rsPatientInfo(&quot;Diagnosis&quot;)%>
</font>
</TD>


<TD BGcolor =&quot;f7efde&quot; align=center>
<font style = &quot;arial narrow&quot; size=2>
<%=rsPatientInfo(&quot;Diagnostic Code&quot;)%>
</font>
</TD>


<TD BGcolor =&quot;f7efde&quot; align=center>
<font style = &quot;arial narrow&quot; size=2>
<%=rsPatientInfo(&quot;SH&quot;)%>
</font>
</TD>


<TD BGcolor =&quot;f7efde&quot; align=center>
<font style = &quot;arial narrow&quot; size=2>
<%=rsPatientInfo(&quot;FrSBE Total&quot;)%>
</font>
</TD>


<TD BGcolor =&quot;f7efde&quot; align=center>
<font style = &quot;arial narrow&quot; size=2>
<%=rsPatientInfo(&quot;DRS Total&quot;)%>
</font>
</TD>



<TD BGcolor =&quot;f7efde&quot; align=center>
<font style = &quot;arial narrow&quot; size=2>
<%=rsPatientInfo(&quot;MMSE Score&quot;)%>
</font>
</TD>



<TD BGcolor =&quot;f7efde&quot; align=center>
<font style = &quot;arial narrow&quot; size=2>
<%=rsPatientInfo(&quot;APeE Genetype&quot;)%>
</font>
</TD>



<TD BGcolor =&quot;f7efde&quot; align=center>
<font style = &quot;arial narrow&quot; size=2>
<%=rsPatientInfo(&quot;Date Of Evaluation&quot;)%>
</font>
</TD>
</TR>

<% rsPatientInfo.MoveNext%>
<%loop %><!-- next row -->

</TABLE>
</CENTER>
<%End if %>
<%End if %>





<p><input type=&quot;submit&quot; value=&quot;Add New&quot; name=&quot;B1&quot;> <input type=&quot;submit&quot; value=&quot;Update&quot;
name=&quot;b1&quot;> <input type=&quot;submit&quot; value=&quot;Delete&quot; name=&quot;b1&quot;> <input type=&quot;submit&quot;
value=&quot;Cancel&quot; name=&quot;b1&quot;> <input type=&quot;submit&quot;
value=&quot;Export&quot; name=&quot;b1&quot;> </p>


</BODY>

</HTML>
 
first task is to find out what submit button was pressed.
javascript on the client would be the process to do this
what you want to do is have a hidden form field in the form. give this form field a name pertaining to the submit types.
eg:<input type=&quot;hidden&quot; name=&quot;submitValue&quot;>
then you change that value on the submit event with a return in the submits via onClick=&quot;return function()&quot;>
the function would look like this with a call of
onClick=&quot;return whichButton(this.name)&quot;
function whichButton(subName) {
if(subName==&quot;delete&quot;) {
return document.formname.submitValue.value=&quot;delete&quot;;
}

now you place the page in a if statement. this way you can check the page for the event occuring on the click of one of the submits
eg:
<%
If Request.Form(&quot;submitValue&quot;) = &quot;delete&quot; Then
run a sql delete for the value
ElseIf Request.Form(&quot;submitValue&quot;) = &quot;submitted&quot; Then
run that condition here
Else
output the HTML page as you have it

don't forget at the bottom of the page to do
<% End If %>


as for the actual deletion of the values. you can add the values as you have them to hidden form fields according to the values outputed as is not in the table. pass this value jsut as you pass the value of the submit event of which button was clicked.



____________________________________________________
get the best answer to your questions by asking the best questions &quot;General FAQ&quot; faq333-2924
onpnt2.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top