| | |
how to get the values of checkboxes and delete them
Please support our ASP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
Hi there,
have you tried to make this work?
well here the way do do this :
ASP :
HTML :
[HTML]
<%else%>
<!-- Form Not Submited Yet-->
<form action="CheckBox.asp" method="post" name="form1" id="form1">
<table border="1" cellspacing="2" cellpadding="2">
<tr>
<td>Delete</td>
<td>User Id</td>
<td>User Name</td>
</tr>
<%
c=0
do while not rs.eof
c=c+1
%>
<tr>
<td><input type="checkbox" name="chkBox" value="<%=rs("uid")%>"></td>
<td><%=rs("uid")%></td>
<td><%=rs("username")%></td>
</tr>
<%
rs.movenext
loop
%>
<tr>
<td colspan="3"><input name="Delete" type="submit" value="Delete" /></td>
</table>
</form>
<%end if%>
[/HTML]
I hope this will useful for you and others!
Regards,
Rahul Dev Katarey
have you tried to make this work?

well here the way do do this :
ASP :
ASP Syntax (Toggle Plain Text)
<% '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]
<%else%>
<!-- Form Not Submited Yet-->
<form action="CheckBox.asp" method="post" name="form1" id="form1">
<table border="1" cellspacing="2" cellpadding="2">
<tr>
<td>Delete</td>
<td>User Id</td>
<td>User Name</td>
</tr>
<%
c=0
do while not rs.eof
c=c+1
%>
<tr>
<td><input type="checkbox" name="chkBox" value="<%=rs("uid")%>"></td>
<td><%=rs("uid")%></td>
<td><%=rs("username")%></td>
</tr>
<%
rs.movenext
loop
%>
<tr>
<td colspan="3"><input name="Delete" type="submit" value="Delete" /></td>
</table>
</form>
<%end if%>
[/HTML]
I hope this will useful for you and others!

Regards,
Rahul Dev Katarey
Last edited by katarey; May 7th, 2007 at 8:48 pm.
Hi Again,
if above code not works so just replace
This Part :
With :
Thanks
Rahul
if above code not works so just replace
This Part :
ASP Syntax (Toggle Plain Text)
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 :
ASP Syntax (Toggle Plain Text)
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
Last edited by katarey; May 7th, 2007 at 9:38 pm.
![]() |
Similar Threads
- asp:repeater in a form? (ASP.NET)
- How to delete using checkboxes (PHP)
- html checkboxes... (PHP)
- IE doesn't work, here is my Hijackthis log... (Viruses, Spyware and other Nasties)
- Problem Unsetting Variables? (PHP)
Other Threads in the ASP Forum
- Previous Thread: alternative to inet control
- Next Thread: I want to make a search engine for my assignment ASP files
| Thread Tools | Search this Thread |
archive asp asp.net aspandmssqlserver2005 aspandmssqlserver2005connection aspconnection connection database databaseconnection dreamweaver excel fso iis msmsql mssql2005 mssqlserver2005 mssqlserver2005andasp mssqlserverandasp opentextfile record searchbox selectoption single specfic sqlserver sqlserverconnection windows7





