Delete All Row (Select All Row Using Radio Button)

This is a discussion on "Delete All Row (Select All Row Using Radio Button)" within the Classic ASP section. This forum, and the thread "Delete All Row (Select All Row Using Radio Button) are both part of the Program Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > Classic ASP

Notices




Closed Thread
 
LinkBack Thread Tools
  #21  
Old Oct 24th, 2004, 09:32
Anonymous User
Guest
Posts: n/a
worked on my pc
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #22  
Old Oct 24th, 2004, 09:33
spinal007's Avatar
Moderator
Join Date: Mar 2004
Location: Good Ol'London
Age: 23
Posts: 1,669
Blog Entries: 1
Thanks: 1
Thanked 4 Times in 4 Posts
sat was me again.... ^^^^
sorry!
Last Blog Entry: Random String in Javascript (Apr 21st, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #23  
Old Oct 24th, 2004, 11:53
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,612
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Hai spinal....
You mean the code that you gave me on the first time worked on your pc? Actually when I throw the viewLec.Close...,the data/row that I am trying to delete is still there and it is not being deleted.

When I click on the Delete text or delete using the checkbox, it display the information that i am tring to delete at the top of my page....

<font size="1">1. Response.Write "LECTURERS TO DELETE: " & Request("delete") & "
"
2. Response.Write "deleting lecturer " & lecturer & " (DELETE * from userlist WHERE (no = " & lecturer & ")) ...
"</font id="size1">

but the data is not being deleted, it still there!

Ok, do I have to change anything in that code? Because I just use your code straight away without changing anything, since I thing there is nothing for me to change!

My first method (the file that I gave you) peform the delete using an action page! This action page is the page that actually peform the delete. but you have actually made the delete operation on the same page as the display page. - my understanding

Spinal...did it actually delete it in your PC?
Help me spinal...I am crying here :sad:
Can you tell me step by step what to do or change in that code (if there is..?)
please...please...please...spinal
anything that you think that I might forgoted to do here?
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #24  
Old Oct 25th, 2004, 03:29
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,612
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Hai spinal...
I have tried double and triple checking the code...
still it wont work!
Please help me spinal...

The result is still the same..
at the top of the page, it display the delete information
(what are the data "the checkbox number value" that i am trying to delete)
But the data is still there...not being deleted!
Is there something wrong with the delete command or somethin?
I am using windows xp,IIS 5, access2000...does that matter
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #25  
Old Oct 27th, 2004, 03:05
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,612
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Hai spinal...
Can you help he again please...
I cannot do it man! What is wrong with the code?

Can you look into it again spinal!
Plase spinal...I am begging you please...

I just need the delete operation works, and my system will be complete!
I just can wait that moment spinal.
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #26  
Old Oct 27th, 2004, 09:42
Rob's Avatar
Rob Rob is offline
Webforumz Founder
Join Date: Jul 2003
Location: Southern UK
Age: 34
Posts: 3,188
Blog Entries: 7
Thanks: 27
Thanked 23 Times in 20 Posts
Monie, please respect that everyone here has a life outside of the forums, and often is the case that people have jobs besides also.

May I respectfully request that you not keep posting (You've made 3 in a row in this thread!!).... instead, just be patient, and you will receive the help you are after.

Being impatient is likely to put people off which wont have your desired effect.

Can you post your FULL code please? (... and then patiently wait for a response? )
__________________
Click the 'Thanks!' button if this post has helped you

Rob - Webforumz Founder
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #27  
Old Oct 27th, 2004, 15:35
Anonymous User
Guest
Posts: n/a
DAMN!

been busy at work, I'll post overnight!

ps.: I logged in this time
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #28  
Old Oct 27th, 2004, 15:45
spinal007's Avatar
Moderator
Join Date: Mar 2004
Location: Good Ol'London
Age: 23
Posts: 1,669
Blog Entries: 1
Thanks: 1
Thanked 4 Times in 4 Posts
doh!
Last Blog Entry: Random String in Javascript (Apr 21st, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #29  
Old Oct 28th, 2004, 03:54
Anonymous User
Guest
Posts: n/a
Ok, I'll wait...
I hope sombody will help me...
Sorry everyone:mad:
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #30  
Old Oct 28th, 2004, 07:17
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,612
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Hai spinal...fuhhhh....!!!!
After 2 long weeks, studying, trying to understand, impliment your code, today..I have discover the problem!

It is a simple small problem. Actually, the code that you gave me, it delete the record reffering to a "no" field in my database. Thats why the code doesnt works! But when I tried to delete reffering to the "username" field using your code, IT WORKS!

The only things that I dont understand here is why when I want to delete using the "no" field, the code doesn't works!

Here is the comparison code!
Code: Select all
This code works!
viewLec.Open "DELETE * from userlist WHERE (username = " & lecturer & ")", conn,3,3
<input type="checkbox" name="delete" value="'<%=viewLec("username")%>'"> I have added the ' symbol!
?delete='<%=viewLec("username")%>'">Delete I add here too..!

This code doesn't works!
viewLec.Open "DELETE * from userlist WHERE (no = " & lecturer & ")", conn,3,3
<input type="checkbox" name="delete" value="<%=viewLec("no")%>">
?delete='<%=viewLec("no")%>'">Delete
<span style="color:red">What changes do I have to make in order to delete reffering to the "no" field (that is not a string!)
"no" in a autonumber unique primary key!</span id="red">


This is the success code deleting using "username" field as the refference to the delete operation.
Code: Select all
<%@ LANGUAGE=VBSCRIPT %>
<% Option Explicit %>
<%

    Dim conn,viewLec,record
    set conn=Server.CreateObject("ADODB.Connection")
    conn.Provider="Microsoft.Jet.OLEDB.4.0"
    conn.Open(Server.Mappath("database\lecturerLogin.mdb"))
    set viewLec = Server.CreateObject("ADODB.recordset")
	
Dim lecturer
Response.Write "LECTURERS TO DELETE: " & Request("delete") & "
"
For Each lecturer In Request("delete")
  Response.Write "Deleting lecturer " & lecturer & " (DELETE * from userlist WHERE (username = " & lecturer & "))...
"
  viewLec.Open "DELETE * from userlist WHERE (username = " & lecturer & ")", conn,3,3
Next 
  viewLec.Open "SELECT * from userlist", conn
%>

<%
Dim Repeat1__numRows,viewLec_numRows
Repeat1__numRows = -1
Dim Repeat1__index
Repeat1__index = 0
viewLec_numRows = viewLec_numRows + Repeat1__numRows
%>

<html>
<head>
<title>View Registered Admin</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<script language = "Javascript">

//Function to check all checkbox
var form='form' //Give the form name here
function SetChecked(val,chkName) {
	dml=document.forms[form];
	len = dml.elements.length;
	var i=0;
	for( i=0 ; i<len ; i++) {
		if (dml.elements[i].name==chkName) {
		dml.elements[i].checked=val;
}
}
}
function ValidateForm(dml,chkName){
len = dml.elements.length;
var i=0;
for( i=0 ; i<len ; i++) {
if ((dml.elements[i].name==chkName) && (dml.elements[i].checked==1)) return true
}
alert("Please select at least one record to be deleted")
return false;
}
</script>

<style type="text/css">
<!--
A:link { COLOR: #164376; TEXT-DECORATION: none}
A:visited {COLOR: #164376; TEXT-DECORATION: none}
A:active { COLOR: #164376; TEXT-DECORATION: none}
A:hover { COLOR: #000000; TEXT-DECORATION: none}
-->
</style>

</head>
<body topmargin="0" bgcolor="#F1F8FC">
<Form Name="Form" Action="<%=Request.ServerVariables("SCRIPT_NAME")%>" method="post" onSubmit="return ValidateForm(this,'delete')">
  

  <div align="center"> 
    <center>
      <table border="1" cellspacing="1" width="100%" id="AutoNumber3" bordercolor="#0D5692" bordercolorlight="#000000" bordercolordark="#000000" bgcolor="#587698" style="border-collapse: collapse">
        <tr> 
          <td width="50%" bgcolor="#587698" bordercolor="#000000" height="10" bordercolorlight="#587698" bordercolordark="#587698"><font size="1" face="Verdana" color="#FFFFFF">Main 
            Page > Register Lecturer > View Registered Lecturer</font></td>
          <td width="50%" bgcolor="#587698" bordercolor="#000000" height="10" bordercolorlight="#587698" bordercolordark="#587698"> 
            <p align="right"><font face="Verdana" size="1" color="#FFFFFF">[<%=FormatDateTime(Date,1)%>]</font>
          </td>
        </tr>
      </table>
    </center>
  </div>
  

  <div align="center"> 
    <center>
      <table border="1" bordercolor="#F1F8FC" width="100%" id="AutoNumber2" height="54">
        <tr> 
          <td width="44" bordercolor="#0D5692" align="center" bordercolorlight="#164376" bordercolordark="#164376" bgcolor="#164376" height="19"> 
            <font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif">Check</font></td>
          <td width="165" bordercolor="#0D5692" align="center" bordercolorlight="#164376" bordercolordark="#164376" bgcolor="#164376" height="19"> 
            <font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif">Lecturer 
            Name</font></td>
          <td width="129" bordercolor="#0D5692" align="center" bordercolorlight="#164376" bordercolordark="#164376" bgcolor="#164376" height="19"><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif">Lecturer 
            ID</font></td>
          <td width="162" bordercolor="#0D5692" align="center" bordercolorlight="#164376" bordercolordark="#164376" bgcolor="#164376" height="19"> 
            <font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif">Email 
            Address</font></td>
          <td width="148" bordercolor="#0D5692" align="center" bordercolorlight="#164376" bordercolordark="#164376" bgcolor="#164376" height="19"><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif">Username</font></td>
          <td width="161" bordercolor="#0D5692" align="center" bordercolorlight="#164376" bordercolordark="#164376" bgcolor="#164376" height="19"> 
            <font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif"><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif">Password</font></font></td>
          <td width="148" bordercolor="#0D5692" align="center" bordercolorlight="#164376" bordercolordark="#164376" bgcolor="#164376" height="19"><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif">Delete</font></td>
        </tr>
<% 
    Dim RowCount,RowColour
    RowCount = 0
    While ((Repeat1__numRows <> 0) AND (NOT viewLec.EOF)) 
      If (RowCount Mod 2)=0 Then RowColour = "#FFFFFF" Else RowColour = "#CEDFED" 
      RowCount = RowCount + 1
%>
        <tr style="background-color:<%=RowColour%>"> 
          <td width="44" bordercolor="#0D5692" height="1" align="center" bordercolorlight="#000000" bordercolordark="#000000"> 
            <div align="center"> 
              <input type="checkbox" name="delete" value="'<%=viewLec("username")%>'">
            </div>
          </td>
          <td width="165" bordercolor="#0D5692" height="1" align="center" bordercolorlight="#000000" bordercolordark="#000000"> 
            <div align="center" style="width: 6; height: 0"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><%Response.Write (viewLec("fullname"))%></font></div>
          </td>
          <td width="129" bordercolor="#0D5692" height="1" align="center" bordercolorlight="#000000" bordercolordark="#000000"> 
            <div align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
              <%Response.Write (viewLec("ID"))%>
              </font></div>
          </td>
          <td width="162" bordercolor="#0D5692" height="1" align="center" bordercolorlight="#000000" bordercolordark="#000000"> 
            <div align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
              <%Response.Write (viewLec("email"))%>
              </font></div>
          </td>
          <td width="148" bordercolor="#0D5692" height="1" align="center" bordercolorlight="#000000" bordercolordark="#000000"> 
            <font size="2" face="Verdana, Arial, Helvetica, sans-serif">
            <%Response.Write (viewLec("username"))%>
            </font></td>
          <td width="161" bordercolor="#0D5692" height="1" align="center" bordercolorlight="#000000" bordercolordark="#000000"> 
            <div align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
              <%Response.Write (viewLec("password"))%>
              </font></div>
          </td>
          <td width="148" bordercolor="#0D5692" height="1" align="center" bordercolorlight="#000000" bordercolordark="#000000"> 
            <font face="Verdana, Arial, Helvetica, sans-serif" style="font-size: 9pt"> 
            ?delete='<%=viewLec("username")%>'">Delete 
            </font></td>
        </tr>
<% 
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  viewLec.MoveNext()
  Wend
%>
      </table>
      
      <input type="submit" value="Delete Selected">
    </center>
  </div>
</Form>
</body>
</html>
<%
viewLec.Close()
%>
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #31  
Old Oct 28th, 2004, 12:01
spinal007's Avatar
Moderator
Join Date: Mar 2004
Location: Good Ol'London
Age: 23
Posts: 1,669
Blog Entries: 1
Thanks: 1
Thanked 4 Times in 4 Posts
glad to know you find the solution to your problem.

the only change you need is to put quotes around thye username in your SQL statement:
DELETE * from userlist WHERE (username = '" & lecturer & "')"
Last Blog Entry: Random String in Javascript (Apr 21st, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #32  
Old Oct 30th, 2004, 02:33
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,612
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Dear spinal...
I just cannot detect what is the problem! The code below is a code to delete using username as the delete refference!
Could you help me, I mean, I have remove the ' symbol, and change the delete refference to my "ID" field (as you said earlier), and it still dont works!

What I want to do is to delete using this:

value="<%=viewLec("ID")%>"

<span style="color:red">but not this:</span id="red">

value="'<%=viewLec("username")%>'"

<span style="color:red">What are the changes that I have to make in the
1. sql delete code,
2. checkbox value and the
3. a href delete text?
</span id="red">

Could you show it to me, please...

This code delete using username,I want to change to delete using ID!
Code: Select all
<%@ LANGUAGE=VBSCRIPT %>
<% Option Explicit %>
<%

    Dim conn,viewLec,record
    set conn=Server.CreateObject("ADODB.Connection")
    conn.Provider="Microsoft.Jet.OLEDB.4.0"
    conn.Open(Server.Mappath("database\lecturerLogin.mdb"))
    set viewLec = Server.CreateObject("ADODB.recordset")
	
Dim lecturer
Response.Write "LECTURERS TO DELETE: " & Request("delete") & "
"
For Each lecturer In Request("delete")
  Response.Write "Deleting lecturer " & lecturer & " (DELETE * from userlist WHERE (username = " & lecturer & "))...
"
  viewLec.Open "DELETE * from userlist WHERE (username = " & lecturer & ")", conn,3,3
  

  'viewLec.Open "DELETE * from userlist WHERE (ID = " & lecturer & ")", conn,3,3

Next 

viewLec.Open "SELECT * from userlistSort", conn
%>
CHECKBOX: change the value to <span style="color:blue">value="<%=viewLec("ID")%>"</span id="blue">
Code: Select all
<input type="checkbox" name="delete" value="'<%=viewLec("username")%>'">
A HREF DELETE: change to <span style="color:blue">value="<%=viewLec("ID")%>"</span id="blue">
Code: Select all
?delete='<%=viewLec("username")%>'">Delete
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #33  
Old Nov 1st, 2004, 09:23
spinal007's Avatar
Moderator
Join Date: Mar 2004
Location: Good Ol'London
Age: 23
Posts: 1,669
Blog Entries: 1
Thanks: 1
Thanked 4 Times in 4 Posts
I wish I could help you but I've been really busy latelly and will be for the next few weeks.

I will try and go through your problem when I get some time but till then, I hope some one else will be able to help you out....
Last Blog Entry: Random String in Javascript (Apr 21st, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #34  
Old Nov 2nd, 2004, 09:11
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,612
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Ok spinal...I'll wait you!

p/s: I want to delete using an ID field but not a "username" field.

Anybody please help me:mad:
Rob..I know you can help me, please.
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #35  
Old Nov 2nd, 2004, 15:42
Rob's Avatar
Rob Rob is offline
Webforumz Founder
Join Date: Jul 2003
Location: Southern UK
Age: 34
Posts: 3,188
Blog Entries: 7
Thanks: 27
Thanked 23 Times in 20 Posts
Drop the quotes from around ID.

ID is an integer field.
Interger fields contain ONLY numbers, and like all other number fields, should be referenced without the quotes.

Just remember quotes for strings, no quotes for numbers.

Hope this helps you... please try and solve this monie.... there has been every single piece of advice given in this thread that you need to solve the task..... We have helped you loads and to me, it just seems as though you want us to make something for you that works and then just hand it to you...... We dont work that way here... we always give people the information needed to solve their own problems.... we try not to solve them in their entirety as this leaves the person with nothing to do, and they do not learn any thing from it.

I hope you understand.

Please post back again if you get stuck, but please dont expect anyone to quote you line by line code..... although we could do that, it really would not help you learn.
__________________
Click the 'Thanks!' button if this post has helped you

Rob - Webforumz Founder
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #36  
Old Nov 5th, 2004, 09:00
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,612
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
I understand you Rob.

Well, for some reason, I have discover the problem, and I would like to share this with you all...

Actually the problem does not come from the code that spinal gave me. It comes from the database. What I have been trying so hard here is I am using my "no" field in my database and I make the checkbox reffering to that field for the delete refference.

A miracle happen to me when I change the database field name from "no" to "RNO", and then the delete successfully done.

So, you guys never encounter any problem like that huh?
So thats mean, all this time, the code works, nobody point me to the database? Well, thanx guys for all the effort. I love webforumz!

Thanx especially to spinal and also Rob
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #37  
Old Nov 5th, 2004, 09:10
spinal007's Avatar
Moderator
Join Date: Mar 2004
Location: Good Ol'London
Age: 23
Posts: 1,669
Blog Entries: 1
Thanks: 1
Thanked 4 Times in 4 Posts
glad to know you sorted it out <