473,387 Members | 1,516 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,387 software developers and data experts.

deleting/adding row in tables using image button

i have 3 4 row of tables which is having dd,textboxes i wanted to delete rows using imagebutton which is along with that row. when u click that button that perticular row should delete it should in AJAX can u help me
Dec 14 '11 #1
1 1931
Dormilich
8,658 Expert Mod 8TB
why would you use AJAX for deleting a HTML element?

let's say you have
Expand|Select|Wrap|Line Numbers
  1. <tr>
  2.   <td>
  3.     <img src="del.gif" class="delete" alt="delete row">
  4.   <td>
  5. <tr>
since the click event knows on which element (<img>) it operates, you can climb up to the next <tr> and delete that.
Expand|Select|Wrap|Line Numbers
  1. function delete_row()
  2. {
  3.   // get the current element
  4.   var current_node = this;
  5.   // climb up the DOM tree
  6.   while ("tr" != current_node.nodeName.toLowerCase()) {
  7.     current_node = current_node.parentNode;
  8.   }
  9.   // delete
  10.   current_node.parentNode.removeChild(current_node);
  11. }
  12. // get all delete-images
  13. var del = document.getElementsByClassName("delete");
  14. // attach event to all images
  15. for (var i = del.length; i--;) {
  16.   del[i].addEventListener("click", delete_row, true);
  17. }
note: if you used a JS library like jQuery, that code becomes even easier.
Dec 14 '11 #2

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

Similar topics

4
by: Ester | last post by:
I have an interior design of a living room with lights and aircond image. My task is to load the living room image without any light and aircond images as background image of a WebForm after that I...
2
by: Ester | last post by:
Instead of drag and drop image button from Toolbox and name the image button id on the properties box, I would like to load image button ID from database. I created a database table that stores...
3
by: Adam | last post by:
Hey guys, I've decided to stop banging my head against the wall and just ask you guys for the answer. I can't seem to find it. I have a form in which I have multiple submit buttons; only, I'm...
2
by: pmud | last post by:
Hi, I am designing a simple ASP.NET web page. I have an image button. What I want to do is: when the cursor is over the image button, a drop down meny should display. This menu should have tabs...
1
by: Phil_Cam | last post by:
Hello All On a webpage I have a standard paypal image button for purchases. I am trying to set it up so that it only shows up or is endabled when text is entered into a textbox and a button is...
0
by: Boricua | last post by:
I'm using ASP.NET 2.0 I got an imagebutton at the end of my form as a submit button. When the user clicks it the button becomes disabled and continues with the postback. This is what I got, ib...
0
by: Carz | last post by:
I have an image dynamically created. An image button is then created using this image. The problem is that it shows up perfectly on my machine, but on others it doesn't. The image is created by...
2
by: smokeyd | last post by:
i am trying to create a simple image button rollover.. i have searched this forum and found a number of solutions but none seem to work. i am just trying to get the onmouseover to swap the image...
2
by: ghjk | last post by:
I'm using image button in php. But it's work only in firefox not in IE. if (isset($_POST)) { echo "hello"; } <input name="submit" value="Submit" src="Submit.jpg" type="image" ...
5
by: Clubsandwich | last post by:
I'm trying to create a button on my GUI that will access a table or query I have created elsewhere and change all of the values of one field to "off". I use this application to create reports based...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.