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.



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

Notices


Closed Thread
 
LinkBack Thread Tools
  #1 (permalink)  
Old Oct 11th, 2004, 02:08
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,608
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Send a message via Yahoo to Monie
Delete All Row (Select All Row Using Radio Button)

Ok guys...
Let say I have an ASP page that will displays all my data in the database.
Each row, I provide a DELETE button so the specific row can be deleted!
This method can be very hard if we are consider to delete all the data with ONE CLICK!

Can anybody guide me on how to use a RADIO BUTTON to select all the row and at the end of the page, there is a DELETE button that will delete whatever row that I have selected to be deleted??:

This is the display database page...
Code: Select all
<% 
While ((Repeat1__numRows <> 0) AND (NOT admin.EOF)) 
%>
      <tr bgcolor="#E6E6E6"> 
        <td width="182" bordercolor="#0D5692" height="1" align="center" bordercolorlight="#000000" bordercolordark="#000000" bgcolor="#FFFFFF"> 
          <div align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><%=(admin.Fields.Item("name").Value)%></font></div>
        </td>
        <td width="120" bordercolor="#0D5692" height="1" align="center" bordercolorlight="#000000" bordercolordark="#000000" bgcolor="#FFFFFF"> 
          <div align="center" style="width: 6; height: 0"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><%=(admin.Fields.Item("ID").Value)%></font></div>
        </td>
        <td width="181" bordercolor="#0D5692" height="1" align="center" bordercolorlight="#000000" bordercolordark="#000000" bgcolor="#FFFFFF"> 
          <div align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><%=(admin.Fields.Item("email").Value)%></font></div>
        </td>
        <td width="115" bordercolor="#0D5692" height="1" align="center" bordercolorlight="#000000" bordercolordark="#000000" bgcolor="#FFFFFF"> 
          <div align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><%=(admin.Fields.Item("username").Value)%></font></div>
        </td>
        <td width="116" bordercolor="#0D5692" height="1" align="center" bordercolorlight="#000000" bordercolordark="#000000" bgcolor="#FFFFFF"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><%=(admin.Fields.Item("password").Value)%></font></td>
        <td width="51" bordercolor="#0D5692" height="1" align="center" bordercolorlight="#000000" bordercolordark="#000000" bgcolor="#FFFFFF"> 
          <div align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
		  ">Delete
		  </font></div>
        </td>
      </tr>
      <% 
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  admin.MoveNext()
Wend
%>
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)

  #2 (permalink)  
Old Oct 11th, 2004, 10:21
spinal007's Avatar
Moderator
Join Date: Mar 2004
Location: Good Ol'London
Age: 22
Posts: 1,620
Blog Entries: 1
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via ICQ to spinal007 Send a message via MSN to spinal007 Send a message via Yahoo to spinal007 Send a message via Skype™ to spinal007
hard?

put this at the top of your page:
Code: Select all
<%
' connect rs to database
For Each record In Request("Delete")
 rs.Open "DELETE * FROM [Table Name] WHERE (ID=" & record & ")"
Next ' record
%>
obviously, connect the recordset to the database and put in your table name

then use this link to delete a record:
Code: Select all
?delete=<%=admin("ID")%>">delete me!
heres the full code:
Code: Select all
<% 
While ((Repeat1__numRows <> 0) AND (NOT admin.EOF)) 
%>

      <tr bgcolor="#E6E6E6"> 
        <td width="182" bordercolor="#0D5692" height="1" align="center" bordercolorlight="#000000" bordercolordark="#000000" bgcolor="#FFFFFF"> 
          <div align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><%=(admin.Fields.Item("name").Value)%></font></div>
        </td>
        <td width="120" bordercolor="#0D5692" height="1" align="center" bordercolorlight="#000000" bordercolordark="#000000" bgcolor="#FFFFFF"> 
          <div align="center" style="width: 6; height: 0"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><%=(admin.Fields.Item("ID").Value)%></font></div>
        </td>
        <td width="181" bordercolor="#0D5692" height="1" align="center" bordercolorlight="#000000" bordercolordark="#000000" bgcolor="#FFFFFF"> 
          <div align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><%=(admin.Fields.Item("email").Value)%></font></div>
        </td>
        <td width="115" bordercolor="#0D5692" height="1" align="center" bordercolorlight="#000000" bordercolordark="#000000" bgcolor="#FFFFFF"> 
          <div align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><%=(admin.Fields.Item("username").Value)%></font></div>
        </td>
        <td width="116" bordercolor="#0D5692" height="1" align="center" bordercolorlight="#000000" bordercolordark="#000000" bgcolor="#FFFFFF"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><%=(admin.Fields.Item("password").Value)%></font></td>
        <td width="51" bordercolor="#0D5692" height="1" align="center" bordercolorlight="#000000" bordercolordark="#000000" bgcolor="#FFFFFF">
 <input type=submit name=Delete value="delete">

          <div align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
          ?delete=<%=admin("ID")%>">Delete
          </font></div>
        </td>
      </tr>
      <% 
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  admin.MoveNext()
Wend
%>
</FORM>
Last Blog Entry: Random String in Javascript (Apr 21st, 2008)
  #3 (permalink)  
Old Oct 13th, 2004, 01:46
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,608
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Send a message via Yahoo to Monie
This is my database connection which will display all data in the recordset!

Code: Select all
<%
set admin = Server.CreateObject("ADODB.Recordset")
admin.ActiveConnection = MM_AdminRegister_STRING
admin.Source = "SELECT * FROM userlistSort"
admin.CursorType = 0
admin.CursorLocation = 2
admin.LockType = 3
admin.Open()
admin_numRows = 0
%>


<%
Dim Repeat1__numRows
Repeat1__numRows = -1
Dim Repeat1__index
Repeat1__index = 0
admin_numRows = admin_numRows + Repeat1__numRows
%>
Looping display database entry (below)...
This code is not working...I mean the delete function is still not working.

What I want to do is, when the user select the row using the radio button, and then later click the DELETE ALL button at the end of the page.
It will then delete all the selected row


<span style="color:red">Can anybody look at my DELETE ALL button?</span id="red">

Code: Select all
<% 
While ((Repeat1__numRows <> 0) AND (NOT admin.EOF)) 
%>
        <tr bgcolor="#E6E6E6"> 
          <td width="182" bordercolor="#0D5692" height="1" align="center" bordercolorlight="#000000" bordercolordark="#000000" bgcolor="#FFFFFF"> 
            <div align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><%=(admin.Fields.Item("name").Value)%></font></div>
          </td>
          
	  <td width="120" bordercolor="#0D5692" height="1" align="center" bordercolorlight="#000000" bordercolordark="#000000" bgcolor="#FFFFFF"> 
            <div align="center" style="width: 6; height: 0"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><%=(admin.Fields.Item("ID").Value)%></font></div>
          </td>
          
          <td width="181" bordercolor="#0D5692" height="1" align="center" bordercolorlight="#000000" bordercolordark="#000000" bgcolor="#FFFFFF"> 
            <div align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><%=(admin.Fields.Item("email").Value)%></font></div>
          </td>
          
          <td width="115" bordercolor="#0D5692" height="1" align="center" bordercolorlight="#000000" bordercolordark="#000000" bgcolor="#FFFFFF"> 
            <div align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><%=(admin.Fields.Item("username").Value)%></font></div>
          </td>
          
          <td width="116" bordercolor="#0D5692" height="1" align="center" bordercolorlight="#000000" bordercolordark="#000000" bgcolor="#FFFFFF">
            <font size="2" face="Verdana, Arial, Helvetica, sans-serif"><%=(admin.Fields.Item("password").Value)%></font>
          </td>
          
          <td width="51" bordercolor="#0D5692" height="1" align="center" bordercolorlight="#000000" bordercolordark="#000000" bgcolor="#FFFFFF"> 
            <div align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> 
            
            <input type="radio" name="radiobutton" value="radiobutton"> 
    
            
            </font></div>
          </td>
        </tr>

<% 
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  admin.MoveNext()
  Wend
%>
</table>

      
      <div align="right">DELETE ALL</div> 
    
</center>
</div>
</form>
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
  #4 (permalink)  
Old Oct 14th, 2004, 03:06
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,608
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Send a message via Yahoo to Monie
??::wink::razz::sad:[xx(]:mad::mad:??:

How to make a DELETE button that will delete all the data inside the RECORDSET that i have specified?
Code: Select all
 
<!!--My recordset to display all data inside userlistSort.mdb--> 
<%
set admin = Server.CreateObject("ADODB.Recordset")
admin.ActiveConnection = MM_AdminRegister_STRING
admin.Source = "SELECT * FROM userlistSort"
admin.CursorType = 0
admin.CursorLocation = 2
admin.LockType = 3
admin.Open()
admin_numRows = 0
%>
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
  #5 (permalink)  
Old Oct 14th, 2004, 10:59
spinal007's Avatar
Moderator
Join Date: Mar 2004
Location: Good Ol'London
Age: 22
Posts: 1,620
Blog Entries: 1
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via ICQ to spinal007 Send a message via MSN to spinal007 Send a message via Yahoo to spinal007 Send a message via Skype™ to spinal007
note:
radio button only allows one selection so you have to use CHECKBOX instead, i.e.:
<input type=checkbox name=delete



then, it's the same thing I posted before:

1. put this at the top of you page:
Code: Select all
<%
' connect rs to database
For Each record In Request("Delete")
 rs.Open "DELETE * FROM [Table Name] WHERE (ID=" & record & ")"
Next ' record
%>

2. put this at the beginning of each row, so the user can select which records should be deleted
Code: Select all
<input type=checkbox name=delete value="<%=admin("ID")%>">


3. use this link deletes one record (put it at the end of each row, within the loop)
Code: Select all
?delete=<%=admin("ID")%>">delete me!

4. the submit button will delete all selected records:
<input type=submit value="Delete Selected Records">
Last Blog Entry: Random String in Javascript (Apr 21st, 2008)
  #6 (permalink)  
Old Oct 15th, 2004, 01:51
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,608
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Send a message via Yahoo to Monie
Hai spinal...
When you write this, <input type=checkbox name=delete value="<%=admin("ID")%>">,is it reffering to my recordset for adnmin ID,because my code for that is <%=(admin.Fields.Item("ID").Value)%>. I am a little bit confuse here

One more..
For the code below, do I have to change anything there?
I dont understand the "SCRIPT_NAME"?
Code: Select all
?delete=<%=admin("ID")%>">delete me!
One last thing...
This is my rs connection, so..you mean I just have to put the code inside it like this??? Can you guide me if i am wrong?
i dont understand this part: WHERE (ID=" & record & ")"
Code: Select all
<!!--My recordset to display all data inside userlist.mdb--> 
<%
set admin = Server.CreateObject("ADODB.Recordset")
admin.ActiveConnection = MM_AdminRegister_STRING
admin.Source = "SELECT * FROM userlist"
admin.CursorType = 0
admin.CursorLocation = 2
admin.LockType = 3
admin.Open()
admin_numRows = 0


For Each record In Request("Delete")
 admin.Open "DELETE * FROM userlist WHERE (ID=" & record & ")"
Next
%>
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
  #7 (permalink)  
Old Oct 15th, 2004, 09:53
spinal007's Avatar
Moderator
Join Date: Mar 2004
Location: Good Ol'London
Age: 22
Posts: 1,620
Blog Entries: 1
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via ICQ to spinal007 Send a message via MSN to spinal007 Send a message via Yahoo to spinal007 Send a message via Skype™ to spinal007
<%=(admin.Fields.Item("ID").Value)%> and <%=admin("ID")%> are the same thing.

then, you must deledt the records before you load the records again so:
Code: Select all
<!!--My recordset to display all data inside userlist.mdb--> 
<%
set admin = Server.CreateObject("ADODB.Recordset")
admin.ActiveConnection = MM_AdminRegister_STRING

'this goes first, delete the records
For Each record In Request("Delete")
 admin.Open "DELETE * FROM userlist WHERE (ID=" & record & ")"
Next

' then open your recordset
admin.Source = "SELECT * FROM userlist"
admin.CursorType = 0
admin.CursorLocation = 2
admin.LockType = 3
admin.Open()
admin_numRows = 0

' you could do it all in one line like this:
' this is the same as your 6 lines above
admin.Open "SELECT * FROM userlist", 0, 2, 3
Last Blog Entry: Random String in Javascript (Apr 21st, 2008)
  #8 (permalink)  
Old Oct 16th, 2004, 02:41
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,608
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Send a message via Yahoo to Monie
Thanx spinal..
Let me try it out first.
I'll let you know the result.
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
  #9 (permalink)  
Old Oct 17th, 2004, 11:20
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,608
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Send a message via Yahoo to Monie
Hai spinal....
I have this problem while executing the delete operation!
Can you look at my code PLEASE.....

THIS IS THE ERROR THAT I GET
Technical Information (for support personnel)

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E10)
[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
/admin/ViewList_RegisteredLecturer.asp, line 8

Line 8 is the: viewLec.Open "DELETE * FROM userlist WHERE (username=" & record & ")"

HERE IS MY DATABASE CONNECTION
Code: Select all
<%
set viewLec = Server.CreateObject("ADODB.Recordset")
viewLec.ActiveConnection = MM_lecturer_STRING



For Each record In Request("Delete")
 viewLec.Open "DELETE * FROM userlist WHERE (username=" & record & ")" 
Next

viewLec.Source = "SELECT * FROM userlistSort"
viewLec.CursorType = 0
viewLec.CursorLocation = 2
viewLec.LockType = 3
viewLec.Open()
viewLec_numRows = 0
%>
Here is my full coding for displaying the userlistSort.mdb database query.
Code: Select all
<Form name="lecturer">
<table width="100%" bgcolor="#587698" style="border-collapse: collapse">
..
..
..
<% 
    While ((Repeat1__numRows <> 0) AND (NOT viewLec.EOF)) 
%>
        <tr bgcolor="#E6E6E6"> 
          <td width="44" bordercolor="#0D5692" height="1" align="center" bordercolorlight="#000000" bordercolordark="#000000" bgcolor="#FFFFFF"> 
            <div align="center"> 
              
	       <!--This is my checkbox button. I put at the beginning of each row. We set the value to be the unique data inside our database, can you tell me the purpose of this!
	       <input type="checkbox" name="delete" value="<%=(viewLec.Fields.Item("username").Value)%>">

            </div>
          </td>
          <td width="165" bordercolor="#0D5692" height="1" align="center" bordercolorlight="#000000" bordercolordark="#000000" bgcolor="#FFFFFF"> 
            <div align="center" style="width: 6; height: 0"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><%=(viewLec.Fields.Item("fullname").Value)%></font></div>
          </td>
          <td width="129" bordercolor="#0D5692" height="1" align="center" bordercolorlight="#000000" bordercolordark="#000000" bgcolor="#FFFFFF"> 
            <div align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><%=(viewLec.Fields.Item("ID").Value)%></font></div>
          </td>
          <td width="162" bordercolor="#0D5692" height="1" align="center" bordercolorlight="#000000" bordercolordark="#000000" bgcolor="#FFFFFF"> 
            <div align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><%=(viewLec.Fields.Item("email").Value)%></font></div>
          </td>
          <td width="148" bordercolor="#0D5692" height="1" align="center" bordercolorlight="#000000" bordercolordark="#000000" bgcolor="#FFFFFF"> 
            <font size="2" face="Verdana, Arial, Helvetica, sans-serif"><%=(viewLec.Fields.Item("username").Value)%></font></td>
          <td width="161" bordercolor="#0D5692" height="1" align="center" bordercolorlight="#000000" bordercolordark="#000000" bgcolor="#FFFFFF"> 
            <div align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><%=(viewLec.Fields.Item("password").Value)%></font></div>
          </td>
          <td width="148" bordercolor="#0D5692" height="1" align="center" bordercolorlight="#000000" bordercolordark="#000000" bgcolor="#FFFFFF"> 
            
             
             ?delete=<%=(viewLec.Fields.Item("username").Value)%>">Delete Me![/b]</font>

	  </td>
        </tr>

<% 
    Repeat1__index=Repeat1__index+1
    Repeat1__numRows=Repeat1__numRows-1
    viewLec.MoveNext()
    Wend
%>
      </table>

      <input type=submit value="Delete Selected Records">

</Form>
</body>
</html>

<%
viewLec.Close()
%>
Basically, the method that I used before this is like this:
when i click the delete button (at the end of each row), it will bring to another page where the delete operation will be done.

What I want to do now is, when i click the delete button, the selected row to be deleted will dissapear automatically without going to another page.
Can you help me with the problem that i am facing here.
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
  #10 (permalink)  
Old Oct 17th, 2004, 15:17
Rob's Avatar
Rob Rob is offline
Head Admin & CEO

SuperMember
Join Date: Jul 2003
Location: at my desk
Age: 34
Posts: 2,952
Blog Entries: 7
Thanks: 7
Thanked 4 Times in 4 Posts
Send a message via MSN to Rob Send a message via Skype™ to Rob
What you want to do is very possible.... but I think you should solve your current problem first in order to learn from it. You appear from the above to be deleting records based on a username.... which must surely be a text type database field.... yet you refer to it as if it were a number... user the following:- [b]viewLec.Open "DELETE * FROM userlist WHERE (username='" & record & "')"[b]

However, may I point out that you really should be deleting records based on the unique identifier (Primary Key).... personally I would use the UserID (or whatever you've called it)
<blockquote id="quote" class="ffs">quote:<hr height="1" noshade="noshade" id="quote" />What I want to do now is, when i click the delete button, the selected row to be deleted will dissapear automatically without going to another page.
Can you help me with the problem that i am facing here.<hr height="1" noshade="noshade" id="quote" /></blockquote id="quote">This is possible. However, you will be placing a critical part of your application's functionality in the hands of javascript.... and this is NEVER a good idea. I thought I would give you the info before you make a decision. Is there anything wrong with spawning a new window using target=_blank for the delete process? This way, the record WILL be deleted regardless of the clients support for javascript.

Some things above for you to think about.
__________________
Rob - SEO Specialist
Owner & Founder of Webforumz.com

I am currently unavailable for private work
  #11 (permalink)  
Old Oct 18th, 2004, 03:12
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,608
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Send a message via Yahoo to Monie
Hai Rob and spinal...
So that mean, when I change the (refer to database field for the delete purpose) "username" to my "no"-(unique auto number in my database) then the code will work?


<span style="color:red">Please help he guys...I have spent more than a week to do this simple task!:sad:</span id="red">

I have a database table called userlist containing Fields: no (autoNumber & primary key also), ID, username (primary Key), password, fullname and email. For now I have refer the "username" fiels instead of the "no" fiels to delete my record...

Ok...this code now refer to the autonumber primary key field "no" in my database..Can you look at it and comment if I have a syntax error or wrong coding technique please.....
Code: Select all
<%@LANGUAGE="VBSCRIPT"%> 




<%
set viewLec = Server.CreateObject("ADODB.Recordset")
viewLec.ActiveConnection = MM_lecturer_STRING


For Each record In Request("Delete")
 viewLec.Open "DELETE * FROM userlist WHERE (no=" & record & ")"
Next

viewLec.Source = "SELECT * FROM userlist"
viewLec.CursorType = 0
viewLec.CursorLocation = 2
viewLec.LockType = 3
viewLec.Open()
viewLec_numRows = 0
%>
<%
Dim Repeat1__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">
</head>

<body topmargin="0" bgcolor="#F1F8FC">
<form name="DeleteChecked">
     
     <table border="1" bordercolor="#F1F8FC" width="100%" id="AutoNumber2" height="1">
        <tr bgcolor="#0D5692"> 
          <td width="44" bordercolor="#0D5692" align="center" bordercolorlight="#164376" bordercolordark="#164376" bgcolor="#164376"> 
            <font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif"></font>
          </td>
          <td width="165" bordercolor="#0D5692" align="center" bordercolorlight="#164376" bordercolordark="#164376" bgcolor="#164376"> 
            <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">
            <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"> 
            <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">
            <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"> 
            <font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif">Password</font>
          </td>
          <td width="148" bordercolor="#0D5692" align="center" bordercolorlight="#164376" bordercolordark="#164376" bgcolor="#164376">
            <font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif">Delete</font>
          </td>
        </tr>


	
<% 
   While ((Repeat1__numRows <> 0) AND (NOT viewLec.EOF)) 
%>
        <tr bgcolor="#E6E6E6"> 
          <td width="44" bordercolor="#0D5692" height="10" align="center" bordercolorlight="#000000" bordercolordark="#000000" bgcolor="#FFFFFF"> 
            <div align="center"> 
              
              
              <input type="checkbox" name="delete" value="<%=(viewLec.Fields.Item("no").Value)%>">
            
            </div>
          </td>
          <td width="165" bordercolor="#0D5692" height="10" align="center" bordercolorlight="#000000" bordercolordark="#000000" bgcolor="#FFFFFF"> 
            <div align="center" style="width: 6; height: 0">
            <font size="2" face="Verdana, Arial, Helvetica, sans-serif">
            <%=(viewLec.Fields.Item("fullname").Value)%></font>
            </div>
          </td>
          <td width="129" bordercolor="#0D5692" height="10" align="center" bordercolorlight="#000000" bordercolordark="#000000" bgcolor="#FFFFFF"> 
            <div align="center">
            <font size="2" face="Verdana, Arial, Helvetica, sans-serif">
            <%=(viewLec.Fields.Item("ID").Value)%></font>
            </div>
          </td>
          <td width="162" bordercolor="#0D5692" height="10" align="center" bordercolorlight="#000000" bordercolordark="#000000" bgcolor="#FFFFFF"> 
            <div align="center">
            <font size="2" face="Verdana, Arial, Helvetica, sans-serif">
            <%=(viewLec.Fields.Item("email").Value)%></font>
            </div>
          </td>
          <td width="148" bordercolor="#0D5692" height="10" align="center" bordercolorlight="#000000" bordercolordark="#000000" bgcolor="#FFFFFF"> 
            <font size="2" face="Verdana, Arial, Helvetica, sans-serif">
            <%=(viewLec.Fields.Item("username").Value)%></font>
            </td>
          <td width="161" bordercolor="#0D5692" height="10" align="center" bordercolorlight="#000000" bordercolordark="#000000" bgcolor="#FFFFFF"> 
            <div align="center">
            <font size="2" face="Verdana, Arial, Helvetica, sans-serif">
            <%=(viewLec.Fields.Item("password").Value)%></font>
            </div>
          </td>
          <td width="148" bordercolor="#0D5692" height="10" align="center" bordercolorlight="#000000" bordercolordark="#000000" bgcolor="#FFFFFF"> 
            
            
            
            ?delete=<%=(viewLec.Fields.Item("no").Value)%>">Delete Me!
            </td>
        </tr>

<% 
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  viewLec.MoveNext()
  Wend
%>
      </table>
                     
                     <input type=submit value="Delete Selected Records">
    </center>
  </div>
</Form>
</body>
</html>
<%
viewLec.Close()
%>
Here is the sample preview of the above code. I have uploaded them in the internet so you can get the idea of my page looks like
http://www40.brinkster.com/evanevie/

Hai spinal and Rob..Do I have to change anything in this code?
What is the "SCRIPT_NAME" refer to?
<font size="1"><A href="<%=Request.ServerVariables("SCRIPT_NAME")%>? delete=<%=(viewLec.Fields.Item("no").Value)%>">Del ete Me!</A></font id="size1">
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
  #12 (permalink)  
Old Oct 19th, 2004, 17:30
spinal007's Avatar
Moderator
Join Date: Mar 2004
Location: Good Ol'London
Age: 22
Posts: 1,620
Blog Entries: 1
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via ICQ to spinal007 Send a message via MSN to spinal007 Send a message via Yahoo to spinal007 Send a message via Skype™ to spinal007
1. you missed the ' around the username (assuming it's a string)

For Each record In Request("Delete")
viewLec.Open "DELETE * FROM userlist WHERE (username='" & record & "')"
viewLec.Close ' close the recordset before you try to open it again
Next


2. <%=Request.ServerVariables("SCRIPT_NAME")%> is the name of the script you're currently viewing so that the link will work, whatever the page is called....
Last Blog Entry: Random String in Javascript (Apr 21st, 2008)
  #13 (permalink)  
Old Oct 20th, 2004, 01:53
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,608
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Send a message via Yahoo to Monie
You mean...all i have to modify here is the "SCRIPT_NAME"??
Are you reffering "SCRIPT_NAME" to be my page name?
I dont understand spinal

Ok...basically...the code that you gave me will be working on that page without any <form action=""> right?

Can you give me some sample


So..I have to add the ' around the & record if the identifier is a number? Am I right?
If it a string, eg: username, dont use that ' symbol?
<blockquote id="quote" class="ffs">quote:<hr height="1" noshade="noshade" id="quote" />For Each record In Request("Delete")
viewLec.Open "DELETE * FROM userlist WHERE (username='" & record & "')"
viewLec.Close ' close the recordset before you try to open it again
Next<hr height="1" noshade="noshade" id="quote" /></blockquote id="quote">
<span style="colorurple">For now, I am trying to delete using my "no field" in my database which is an auto number primary key, I am not using the "username" field anymore</span id="purple">

<blockquote id="quote" class="ffs">quote:<hr height="1" noshade="noshade" id="quote" />For Each record In Request("Delete")<hr height="1" noshade="noshade" id="quote" /></blockquote id="quote">
Is "Delete" a function or does it refer to any id name?
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
  #14 (permalink)  
Old Oct 20th, 2004, 08:36
spinal007's Avatar
Moderator
Join Date: Mar 2004
Location: Good Ol'London
Age: 22
Posts: 1,620
Blog Entries: 1
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via ICQ to spinal007 Send a message via MSN to spinal007 Send a message via Yahoo to spinal007 Send a message via Skype™ to spinal007
Request("Delete") fetches all the submitted values for the checkbox names "Delete"

<%=Request.ServerVariables("SCRIPT_NAME")%> RETRIEVES THE CURRENT PAGE ADDRESS, SO WHATEVER YOU CALLED YOUR PAGE, LEAVE THIS ALONE!

you have to enclose strings with ', not numbers!!!!!!!!!!!
Last Blog Entry: Random String in Javascript (Apr 21st, 2008)
  #15 (permalink)  
Old Oct 20th, 2004, 11:22
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,608
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Send a message via Yahoo to Monie
I am sorry spinal...:sad:
I am very blank here. I am very not happy until I successfully complete this function. Could you spent more of your time with me please.
Actually I have done my asp page using Macromedia Ultradev4. You can just click without typing any code to it (auto generate codes) Maybe that is the reason why I am having trouble with CODING....
Basically...I am in the process of learning that auto generated code.

I have studied lots of code from the internet especially this link that I got from planetsourcecode...Its kind of easy but still when I follow every single step, it still not working! Check Deleting Record Using CheckBox

I have posted my file that consist of the Display page, Delete page and also my Database...All of them is working except for the <span style="color:red">Delete using checkbox</span id="red"> and the <span style="color:red">Delete by row</span id="red">. Could you download it and run them in your PC and take a look whats wrong with the code, please...

<font size="1">Right click and save target as..</font id="size1">
DOWNLOAD MY CODE HERE

I hope that you can take a look at it spinal...
I would be grateful if you help me. I know this is a simple problem for you guys....yet I am still in my dark life trying to achieve them.
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
  #16 (permalink)  
Old Oct 20th, 2004, 15:21
spinal007's Avatar
Moderator
Join Date: Mar 2004
Location: Good Ol'London
Age: 22
Posts: 1,620
Blog Entries: 1
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via ICQ to spinal007 Send a message via MSN to spinal007 Send a message via Yahoo to spinal007 Send a message via Skype™ to spinal007
there!

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 (no = " & lecturer & ")) ...
"
  viewLec.Open "DELETE * from userlist WHERE (no = " & lecturer & ")", conn,3,3
  viewLec.Close
Next

	viewLec.Open "SELECT * from userlist", conn	
   'set viewLec = conn.execute("SELECT * from userlist") <!-Other way to display data->
%>
<%
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">
</head>
<body topmargin="0" bgcolor="#F1F8FC">
<Form Name="Form" Action="<%=Request.ServerVariables("SCRIPT_NAME")%>" method="post">
  

  <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, Aria