473,399 Members | 3,106 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,399 software developers and data experts.

javascript - delete row

76
hi,
i have a problem with my php+javascript, and i am new to both. the script takes input, and displays them into separate tables. i following script does a part of what i wanted to do, ie, it deletes the table sitting inside another one as a row, but it does it for just the first one if i have, lets say, 3 input. the two other delete buttons don't work at all. please help me figure out what's wrong, and how can i fix it.
thanks a lot in advance.

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. function deleteRow(r){
  5.         var i=r.parentNode.parentNode.rowIndex;
  6.         document.getElementById('myTable').deleteRow(i);
  7. }
  8. </script>
  9. </head>
  10. <?php
  11. $NUM = $_POST["NUM"];
  12. if (!$NUM){
  13. ?>
  14.         <form action="./script.php" method="post">
  15.         <textarea name="NUM" rows="8" cols="60"></textarea>
  16.         <BR>
  17.         <input type="submit" value="Click here to search">
  18.         <input type="reset" value="Clear" >
  19.         </form>
  20.         <?php  
  21. }else{
  22. $NUM = $_POST["NUM"];
  23. $array = preg_split ("/[\s]+/", $NUM);
  24. foreach ($array as $number) {
  25. $number = trim($number);
  26. $text_info = curl_init("http://domain.com/$number");
  27. ....
  28. (parse the data and let's say assign a value to $info)
  29. ....
  30. echo "<TABLE BORDER=0 ID=\"myTable\" WIDTH=500>";
  31. echo "<TR><TD>";
  32. echo "<TABLE BORDER=1>";
  33. echo "<TR><TD><B>Info:</B></TD><TD> $info </TD></TR>";
  34. echo "</TABLE></TD>";
  35. echo "<TD><input type=\"button\" value=\"Delete\" onclick=\"deleteRow(this)\"></TD></TR>";
  36. echo "</TABLE>";
  37. }
  38. }                
  39. ?>
  40.  
  41.  
Feb 18 '08 #1
3 2987
acoder
16,027 Expert Mod 8TB
Do you get an error? Show the HTML output for three rows, i.e. what you can see in the browser.
Feb 18 '08 #2
idorjee
76
i don't get any kinda error messages on the browser. it's just that only one of the tables get deleted (ie the first one), and doesn't do the same for the next tables when i click the delete button for it. the bit of javascript at the top seems do it's thing just once and than nothing. by the way, my output on the browse is just html tables in rows with a delete button as <td> part of the each row. thanks.
i would appreciate your help with this.
Feb 18 '08 #3
acoder
16,027 Expert Mod 8TB
I tested this with a table with three rows, e.g.
[html]<TABLE BORDER=0 ID="myTable" WIDTH=500>
<TR>
<TD>
<TABLE BORDER=1>
<TR>
<TD><B>Info:</B></TD>
<TD> Test </TD>
</TR>
</TABLE>
</TD>
<TD><input type="button" value="Delete" onclick="deleteRow(this)"></TD>
</TR>
<TR>
<TD>
<TABLE BORDER=1>
<TR>
<TD><B>Info:</B></TD>
<TD> Test 2 </TD>
</TR>
</TABLE>
</TD>
<TD><input type="button" value="Delete" onclick="deleteRow(this)"></TD>
</TR>
<TR>
<TD>
<TABLE BORDER=1>
<TR>
<TD><B>Info:</B></TD>
<TD> Test 3 </TD>
</TR>
</TABLE>
</TD>
<TD><input type="button" value="Delete" onclick="deleteRow(this)"></TD>
</TR>
</TABLE>[/html]and it works fine.
Feb 19 '08 #4

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

Similar topics

2
by: Miles Davenport | last post by:
My Javascript is rather rusty :( ... and I need to do change some form values, in the folowing way: (1). I have the following a href (wrapped in PHP), which calls processForm. ==== <input...
1
by: cheezebeetle | last post by:
ok, so I am having problems passing in an ASPX function into the Javascript in the codebehind page. I am simply using a confirm call which when they press "OK" they call this ASPX function, when...
1
by: Muhammad Abdullah | last post by:
Hi am having some problems with the javascript confirm. i have it working fine on one page and it doesnt even pop up at the other. The code on the working page is, private void...
3
by: J.P. Cummins | last post by:
In my ASP.NET application, I wish to have a page for administrators to edit items in a list. Preferably, I would like to use the javascript prompt for the 'rename' function, and a javascript alert...
7
by: julian.tklim | last post by:
Hi, I need to build an editable Datagrid with add & delete buttons on each row using javascript. DataGrid need not be pre-populated with values. To make the thing complicated, one of the...
1
dmjpro
by: dmjpro | last post by:
Here is a code snippet i tried out. var array = new Array(12,20,"Debasis Jana"); alert(array.length); delete array.length; alert(array.length); Basically first i tried to delete the...
3
by: nigelesquire | last post by:
Please help! I'm trying to clone and delete multiple rows with JavaScript. I need two delete buttons that work...! I only have one for now, but it's not working properly, the output count is...
29
by: shivasusan | last post by:
Hi! I can add rows with inputs to my HTML table dynamically using DOM, but I cannot remove selected rows. In fact, every row contains a Delete button. So, user selects the rows to remove, clicks...
0
by: atencorps | last post by:
Hello I have the following code but need some help on it. The idea of the code is the main sections ie Service Management are viewable when the page is loaded and by clicking on the main...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.