473,322 Members | 1,719 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

delete some checkbox rows while click the delete button

29
Hi

I have one table, in that contain deletebutton and some checkboxes.How many checkbox is selected, that is delete while click the deletebutton .

Please reply urgently..........

Thank in Advance
Jun 30 '07 #1
9 19594
gits
5,390 Expert Mod 4TB
hi ...

what have you done so far? post some code so that we may help you with your problem ... try to simplify it to let us see the particular problem you have. as far as i understand: you have a table where you have a checkbox per row ... when you hit a delete-button you want all table-rows to be deleted where the row's checkbox is checked?

kind regards ...
Jun 30 '07 #2
kovik
1,044 Expert 1GB
Please reply urgently..........
First and foremost, your post is no more urgent than anyone else's. Secondly, you haven't asked a question. How can we answer? @_@
Jul 1 '07 #3
cygsoft
29
Hi,

I post my code here ,In this code I have one deletebutton, while i click the deletebutton if checkboxes is not select one alert box is display, if one or more than one checkbox is select confirm box is display that time I want click ok means that selected checkbox rows should delete.


function checkCheckboxes()
{
var e=document.getElementsByName("delId[]");
for (i=0;i<e.length;i++)
{
if (e[i].checked==true)
{

var agree=confirm('Are you sure you want to delete these email addresses?');

if (agree)

{ return true; }

else

{ return false;
}
}

}
alert('You must select an email address to delete');
return false;
}


Thanks in Advance
Jul 2 '07 #4
gits
5,390 Expert Mod 4TB
hi ...

go through the code an have a look at the comments ... tell me more about your html-code (post some of it with the row you mean and the button) ... ok?

Expand|Select|Wrap|Line Numbers
  1. function checkCheckboxes() {
  2.     // gets a collection of nodes that have the name='delId[]';
  3.     var e = document.getElementsByName("delId[]");
  4.  
  5.     // now you loop through the list of nodes
  6.     for (i = 0; i < e.length; i++) {
  7.  
  8.         // everytime you find a checked-box you ask for beeing
  9.         // sure to delete
  10.         if (e[i].checked==true) {
  11.  
  12.             // when agreed the row may be deleted?
  13.             var agree = confirm('Are you sure ...');
  14.  
  15.             if (agree) {
  16.                 // here you need something to delete the row?
  17.                 // show me some html of you - you need a reference
  18.                 // to the row you want to delete ... when having a
  19.                 // look to your html-code we may help you
  20.                 return true;
  21.             } else {
  22.                 // row shouldn't be deleted
  23.                 return false;
  24.             }
  25.         }
  26.  
  27.     }
  28.  
  29.     alert('You must select an email address to delete');
  30.  
  31.     return false;
  32. }
  33.  
kind regards ...
Jul 2 '07 #5
cygsoft
29
hi,

I post the HTML code here,


[HTML]<HTML><HEAD><TITLE>Delete</TITLE>
<SCRIPT language="Javascript">
function checkCheckboxes()
{
var e=document.getElementsByName("delId[]");
for (i=0;i<e.length;i++)
{
if (e[i].checked==true)
{

var agree=confirm('Are you sure you want to delete these email addresses?');

if (agree)

{ return true; }

else

{ return false;
}
}

}
alert('You must select an email address to delete');
return false;
}


</SCRIPT>

</HEAD>
<BODY>
<FORM name="myform">
<INPUT onclick="checkCheckboxes()" type="button" value="Delete"><BR>
<TABLE id="tblSample">
<TBODY>
<TR id="d1">
<TD><INPUT id="delId[]" type="checkbox"> a <SPAN style="MARGIN-LEFT: 250px">Edit
</A>|Delete<BR></SPAN>
</TD></TR>
<TR id="d2">
<TD><INPUT id="delId[]" type="checkbox"> b <SPAN style="MARGIN-LEFT: 250px">Edit
</A>| Delete<BR></SPAN>
</TD></TR>
<TR id="d3">
<TD><INPUT id="delId[]" type="checkbox"> c <SPAN style="MARGIN-LEFT: 250px">Edit
</A>| Delete<BR></SPAN>
</TD></TR>
<TR id="d4">
<TD><INPUT id="list1" type="checkbox"> d <SPAN style="MARGIN-LEFT: 250px">Edit
</A>|Delete<BR></SPAN>
</TD></TR>
</TBODY></TABLE></FORM></BODY></HTML>
[/HTML]Please post using code tags - moderator
Thanks in Advance
Jul 2 '07 #6
gits
5,390 Expert Mod 4TB
have a look at the following example ... i adapted it note the following things with it:

- you use getElementsByName so set the name not id
- declare i in the for loop
- have a look how to remove the line
- please write all tagnames in lowercase (the same for style-properties) ... i didn't adapt that

[HTML]<html>
<TITLE>Delete</TITLE>

<SCRIPT language="Javascript">
function checkCheckboxes() {
var e = document.getElementsByName("delId");

for (var i = 0; i < e.length; i++) {
var c_box = e[i];

if (c_box.checked == true) {

var message = 'Are you sure you want to delete?';

if (window.confirm(message)) {
var row = c_box.parentNode;
var tb = row.parentNode;
tb.removeChild(row);
return true;
} else {
return false;
}
}

}

alert('You must select an email address to delete');
return false;
}
</SCRIPT>
</HEAD>
<BODY>
<FORM name="myform">
<INPUT onclick="checkCheckboxes()" type="button" value="Delete"><BR>
<TABLE id="tblSample">
<TBODY>
<TR id="d1">
<TD><INPUT name="delId" type="checkbox"> a <SPAN style="MARGIN-LEFT: 250px">Edit
</A>|Delete<BR></SPAN>

</TD></TR>
<TR id="d2">
<TD><INPUT name="delId" type="checkbox"> b <SPAN style="MARGIN-LEFT: 250px">Edit
</A>| Delete<BR></SPAN>
</TD></TR>
<TR id="d3">
<TD><INPUT name="delId" type="checkbox"> c <SPAN style="MARGIN-LEFT: 250px">Edit
</A>| Delete<BR></SPAN>

</TD></TR>
<TR id="d4">
<TD><INPUT name="list1" type="checkbox"> d <SPAN style="MARGIN-LEFT: 250px">Edit
</A>|Delete<BR></SPAN>
</TD></TR>
</TBODY>
</TABLE>
</FORM>
</BODY>
</HTML>
[/HTML]
kind regards ...
Jul 2 '07 #7
cygsoft
29
hi,

Thankyou very much for your solution, but it support to delete one row alone, if I select more than one checkbox rows, it does not support, it support to delete first selected checkbox row.
So please give the solution.

Thanks in Advance.
Jul 3 '07 #8
gits
5,390 Expert Mod 4TB
;) hey ... i adapted your code to make it work ;)) ... since it didn't work at all ... so have a close look at the code and try to adapt it for yourself first ... when you got questions ... come back and i will be glad to help you out ...

hint: if something is to delete e.length > 0 with checked boxes in respect, don't use the confirm within the loop, don't return out of the function during the remove-operation ...

kind regards
Jul 3 '07 #9
gits
5,390 Expert Mod 4TB
... hmmm ... had a little time ;)

have a look at the following function that may replace the above one:

Expand|Select|Wrap|Line Numbers
  1. function checkCheckboxes() {
  2.     var e = document.getElementsByName("delId");
  3.     var message  = 'Are you sure you want to delete?';
  4.     var row_list = {length: 0};
  5.  
  6.     for (var i = 0; i < e.length; i++) {
  7.         var c_box = e[i];
  8.  
  9.         if (c_box.checked == true) {
  10.             row_list.length++;
  11.  
  12.             row_list[i] = {};
  13.             row_list[i].row = c_box.parentNode.parentNode;
  14.             row_list[i].tb  = row_list[i].row.parentNode;
  15.         }
  16.     }
  17.  
  18.     if (row_list.length > 0 && window.confirm(message)) {
  19.         for (i in row_list) {
  20.             if (i == 'length') {
  21.                 continue;
  22.             }
  23.  
  24.             var r = row_list[i];
  25.             r.tb.removeChild(r.row);
  26.         }
  27.     } else if (row_list.length == 0) {
  28.         alert('You must select an email address to delete');
  29.     }
  30. }
  31.  
but the next time ... try something for yourself first!

kind regards ...
Jul 3 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Stewart Graefner | last post by:
What do I need to use to be able to make information in a table be deleteable by a User? The table I have tracks Vacation time. It has two fields Vacation Dates and Days taken(Default value 0). The...
1
by: J | last post by:
Hi, Can someone please help with a problem I have. The BOL I think are useless in explaining what I want to do. I have a datagrid, that is bound to a dataview. I have a checkbox as a...
9
by: Dejan | last post by:
Hy, Sorry for my terreble english I have this simple code for deleting rows in mysql table... Everything works fine with it. So, what do i wanna do...: my sql table looks something like...
1
by: Kevin R | last post by:
This is one of the weirdest problems I have ever run into. I have had to trim down a bunch of code to give a sample that is more easily readable by those who will view this. Here is the problem:...
6
by: polocar | last post by:
Hi, I'm writing a program in Visual C# 2005 Professional Edition. This program connects to a SQL Server 2005 database called "Generations" (in which there is only one table, called...
0
by: rn5a | last post by:
All the rows in a DataGrid are accompanied by a CheckBox. When a user checks the rows & clicks a Button, the checked rows get deleted. For e.g. assume that the DataGrid displays 10 rows. A user...
4
imarkdesigns
by: imarkdesigns | last post by:
Hello everyone.. a newbie programmer here wants to ask why is my codes for deleting rows from my databse won't work.... seems that this codes spread to the net and no one refuse to correct it... ...
2
by: Michael | last post by:
It seems that a gridview allows us to delete only a single row at a time. How to extend this functionality to select multiple rows and delete all of the selected rows in a single stroke? just like...
1
by: ahilar12 | last post by:
Hi all, I am new to php,my question is that in this following code i am retrieving many rows from the database which is working good.i want to delete a particular row(s) which is checked(checkbox)...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.