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

Can some fix this code? Delet table rows.

Thanks for any help in advance!

I have this order form where you add rows as you need them. The
routine to add fields is working fine. I am trying to add the ability
to delete rows if you check the checkbox in the cooresponding field
and click remove item.

I would appreciate any insite. BTW Am using IE browsers only.

Thanks!


<SCRIPT LANGUAGE="JScript">
var oRow;
var box;
var itemquantity;
var itemdescription;
var itemtax;
var itemprice;
var itemserial;

function addvalue(f)
{
var oCell;
var i, j;
var check="";

// Insert rows and cells into the first body.

//Get the current row count. Then change item name number
for(i=0; i<1;i++)
{

//Get the row count to make distinct field names
varItem=oTable.rows.length;

//Start Entering At Top Of Table
oTBody0.scrollTop=true;

//Insert A New Row
oRow = oTBody0.insertRow();

//Insert New Action Cell
oCell = oRow.insertCell();
box = "<INPUT type=checkbox class=checkbox name=checkbox id=chkBX
value=check >";
oCell.innerHTML = box

//Insert New Quantity Cell
oCell = oRow.insertCell();
itemquantity = "<input type=text size=8 name=ItemQuantity_"
+varItem+ ">";
//itemquantity = "<input type=text name=Item_Quantity_1 size=8>";
oCell.innerHTML = itemquantity

//Insert New Description Cell
oCell = oRow.insertCell();
itemdescription = "<input type=text size=60 name=ItemDescription_"
+varItem+ ">";
oCell.innerHTML = itemdescription

//Insert New Serial Cell
oCell = oRow.insertCell();
itemserial = "<input type=text size=12 name=ItemSerial_" +varItem+
">";
oCell.innerHTML = itemserial

//Insert Unit Price Cell
oCell = oRow.insertCell();
itemprice = "<input type=text size=9 name=ItemPrice_" +varItem+
">";
oCell.innerHTML = itemprice

//Insert New Tax Cell
oCell = oRow.insertCell();
itemtax = "<input type=text size=3 name=ItemTax_" +varItem+ ">";
oCell.innerHTML = itemtax
}
}
function removevalue()
{
if(oTable.rows.length>0)
{
for(var i=7; i<(oTable.rows.length+7); i++)
{
alert(oTable.rows.length)
alert(document.forms[0].elements[i].value+" ALERTING")
if(document.forms[0].elements[i].checked==true)
{
alert(oTable.rows.length)
//oRow.sectionRowIndex=i;
alert(box.value+"oooooooooooooooooo")
oTable.deleteRow(oTable.rows[i])
}
}
}
}
</script>

<table width="100%" border="0" cellspacing="0" cellpadding="0">
<form action="" name="test" id="test">
<tr>
<td width="100%" colspan="100%">
<input type="button" name="add" value="Add Item" class="button"
onClick="addvalue(this.form)">
<input type="button" name="remove" value="Remove Item"
class="button" onClick="removevalue(this)">
</td>
</tr>
</table>
<BR>
<table width="100%" border="0" cellspacing="0" cellpadding="0"
id="oTable">
<TBODY ID="oTBody0">
<tr>
<td class="label">&nbsp;</td>
<td class="label">Quantity:</td>
<td class="label">Item:</td>
<td class="label">Serial:</td>
<td class="label">Unit Price:</td>
<td class="label">Tax:</td>
</tr>
</TABLE>
</FORM>

cr********@hotmail.com
Jul 20 '05 #1
2 4862

"Spanky" <cr********@hotmail.com> schreef in bericht
news:bc**************************@posting.google.c om...

I have this order form where you add rows as you need them. The
routine to add fields is working fine. I am trying to add the ability
to delete rows if you check the checkbox in the cooresponding field
and click remove item.


This ought to do it:

function removevalue(form) {
var checkboxes = form.elements['checkbox'];
if (!checkboxes) return;
for (var i = 0; i < checkboxes.length; i++) {
if (checkboxes[i].checked) {
document.getElementById('oTBody0').deleteRow(i + 1);
removevalue(form);
}
}
}

Call it the same way as you call addvalue()
JW

Jul 20 '05 #2
"Janwillem Borleffs" <jw*@jwbfoto.demon.nl> wrote in message news:<3f***********************@news.euronet.nl>.. .
"Spanky" <cr********@hotmail.com> schreef in bericht
news:bc**************************@posting.google.c om...

I have this order form where you add rows as you need them. The
routine to add fields is working fine. I am trying to add the ability
to delete rows if you check the checkbox in the cooresponding field
and click remove item.


This ought to do it:

function removevalue(form) {
var checkboxes = form.elements['checkbox'];
if (!checkboxes) return;
for (var i = 0; i < checkboxes.length; i++) {
if (checkboxes[i].checked) {
document.getElementById('oTBody0').deleteRow(i + 1);
removevalue(form);
}
}
}

Call it the same way as you call addvalue()
JW


PERFECT!!! Thanks JW
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Avi | last post by:
Hi All. This code works very fine in Firefox but not in I.E. Can anybody help me out? it gives ... "Unknown Runtime Error" in I.E. This code ... Stores N*2 Matrix at Client Side & provide the...
2
by: Anita C | last post by:
Hi, How do I associate or map a specific column in a datatable to a particular element present in an xml document - to read into a datatable as well as write from the datatable to the xml element?...
5
by: Richard Dixson | last post by:
I created a new C# web application. Basically all I am trying to do is create a table that consists of a few rows with two columns in each. And then to set those columns to text values from my...
5
by: loc2006 | last post by:
I got this tablesort code from http://www.brainjar.com/dhtml/tablesort/default7.asp This is very slow for my table of 10 columns and 400 rows. Is there a way to optimize this code make it...
1
by: Neo Geshel | last post by:
I am having conflicting results with two pieces of identical code. One is an insert, the other is an update to a db. The first code, which works, is this: Sub Add3_Click(sender As Object, e As...
4
by: Frank List | last post by:
Hi, I've run into this problem many times and have not found a good solution yet. Here's what I have: table ParentTable - the "1" table table ChildTable- the "many" table ParentTable...
0
by: toyin | last post by:
hello, pls help look through this code its not inserting the record in dataset into the another database. i want to insert the row in the dataset into another table in another database. pls help....
3
by: xmail123 | last post by:
Why does this code work? I am new to C# and have been studying this piece of code. It loops through an Adjacency Matrix table to populate a tree view. I have two questions about why this code...
3
by: humsafar | last post by:
#include <iostream.h> #include <stdlib.h> #include <stdio.h> Class StudyProgram { Public: StudyProgram (); Void add StudyProgram (); Void edit StudyProgram (); Void delete StudyProgram ();
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: 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
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.