954,566 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

how to get the values of checkboxes and delete them

i want to get the checked checkboxes values to get deleted from the database.can u please help me in this ........................urgent.

pavsuri
Newbie Poster
1 post since May 2007
Reputation Points: 10
Solved Threads: 0
 

Hi there,
have you tried to make this work? ;)
well here the way do do this :
ASP :

<%
'declare variables
Dim connstring, cn, rs
'Connection String
connString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("/conn/db1.mdb")
Sub OpenDataBase()
	Set cn = Server.CreateObject("ADODB.CONNECTION")
	cn.open connstring
End Sub
	'Open Database 
		OpenDataBase()
	'Create Recordset
		set rs = Server.CreateObject("ADODB.Recordset")
		sql = "Select * from users"
		rs.Open sql, cn
'If Form Submit this part will Execute		
if Request.Form("Delete") = "Delete" then	
	'Get All Checked checkbox
	checks = Request.Form("chkBox")
	'checkbox array 	
	check_a = split(checks, ",")		
	'SQL	
	str = ""
	str = "Delete from users where "
	'Adding checked checkbox values to Sql string
	for i = 0 to ubound(check_a)
		if i = 0 then
			str = str & "uid = "& check_a(i)
		else
			str = str & " AND uid = "& check_a(i)
		end if
	next
	'Open Database 
	 OpenDataBase()
		'Execute SQL String
		cn.execute(str)	
		Response.Write "Record Deleted!"
%>


HTML :
[HTML]
<%else%>


Delete
User Id
User Name

<%
c=0
do while not rs.eof
c=c+1
%>
">
<%=rs("uid")%>
<%=rs("username")%>

<%
rs.movenext
loop
%>


<%end if%>
[/HTML]

I hope this will useful for you and others! :)

Regards,
Rahul Dev Katarey

katarey
Junior Poster
167 posts since Jul 2005
Reputation Points: 39
Solved Threads: 23
 

Hi Again,

if above code not works so just replace

This Part :

for i = 0 to ubound(check_a)
		if i = 0 then
			str = str & "uid = "& check_a(i)
		else
			str = str & " AND uid = "& check_a(i)
		end if
	next


With :

for i = 0 to ubound(check_a)
		if i = 0 then
			str = str & "uid = "& check_a(i)
		else
			str = str & " OR uid = "& check_a(i)
		end if
	next


Thanks
Rahul

katarey
Junior Poster
167 posts since Jul 2005
Reputation Points: 39
Solved Threads: 23
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You