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
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 ...
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? @_@
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
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? -
function checkCheckboxes() {
-
// gets a collection of nodes that have the name='delId[]';
-
var e = document.getElementsByName("delId[]");
-
-
// now you loop through the list of nodes
-
for (i = 0; i < e.length; i++) {
-
-
// everytime you find a checked-box you ask for beeing
-
// sure to delete
-
if (e[i].checked==true) {
-
-
// when agreed the row may be deleted?
-
var agree = confirm('Are you sure ...');
-
-
if (agree) {
-
// here you need something to delete the row?
-
// show me some html of you - you need a reference
-
// to the row you want to delete ... when having a
-
// look to your html-code we may help you
-
return true;
-
} else {
-
// row shouldn't be deleted
-
return false;
-
}
-
}
-
-
}
-
-
alert('You must select an email address to delete');
-
-
return false;
-
}
-
kind regards ...
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
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 ...
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.
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
gits 5,390
Expert Mod 4TB
... hmmm ... had a little time ;)
have a look at the following function that may replace the above one: -
function checkCheckboxes() {
-
var e = document.getElementsByName("delId");
-
var message = 'Are you sure you want to delete?';
-
var row_list = {length: 0};
-
-
for (var i = 0; i < e.length; i++) {
-
var c_box = e[i];
-
-
if (c_box.checked == true) {
-
row_list.length++;
-
-
row_list[i] = {};
-
row_list[i].row = c_box.parentNode.parentNode;
-
row_list[i].tb = row_list[i].row.parentNode;
-
}
-
}
-
-
if (row_list.length > 0 && window.confirm(message)) {
-
for (i in row_list) {
-
if (i == 'length') {
-
continue;
-
}
-
-
var r = row_list[i];
-
r.tb.removeChild(r.row);
-
}
-
} else if (row_list.length == 0) {
-
alert('You must select an email address to delete');
-
}
-
}
-
but the next time ... try something for yourself first!
kind regards ...
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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:...
|
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...
|
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...
|
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...
...
|
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...
|
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)...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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....
|
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
|
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...
|
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...
| |