473,789 Members | 2,550 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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="JScri pt">
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.scrollT op=true;

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

//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=ItemQuanti ty_"
+varItem+ ">";
//itemquantity = "<input type=text name=Item_Quant ity_1 size=8>";
oCell.innerHTML = itemquantity

//Insert New Description Cell
oCell = oRow.insertCell ();
itemdescription = "<input type=text size=60 name=ItemDescri ption_"
+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.ro ws.length)
alert(document. forms[0].elements[i].value+" ALERTING")
if(document.for ms[0].elements[i].checked==true)
{
alert(oTable.ro ws.length)
//oRow.sectionRow Index=i;
alert(box.value +"ooooooooooooo ooooo")
oTable.deleteRo w(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="addval ue(this.form)">
<input type="button" name="remove" value="Remove Item"
class="button" onClick="remove value(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">Q uantity:</td>
<td class="label">I tem:</td>
<td class="label">S erial:</td>
<td class="label">U nit Price:</td>
<td class="label">T ax:</td>
</tr>
</TABLE>
</FORM>

cr********@hotm ail.com
Jul 20 '05 #1
2 4888

"Spanky" <cr********@hot mail.com> schreef in bericht
news:bc******** *************** ***@posting.goo gle.com...

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(for m) {
var checkboxes = form.elements['checkbox'];
if (!checkboxes) return;
for (var i = 0; i < checkboxes.leng th; i++) {
if (checkboxes[i].checked) {
document.getEle mentById('oTBod y0').deleteRow( i + 1);
removevalue(for m);
}
}
}

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

Jul 20 '05 #2
"Janwillem Borleffs" <jw*@jwbfoto.de mon.nl> wrote in message news:<3f******* *************** *@news.euronet. nl>...
"Spanky" <cr********@hot mail.com> schreef in bericht
news:bc******** *************** ***@posting.goo gle.com...

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(for m) {
var checkboxes = form.elements['checkbox'];
if (!checkboxes) return;
for (var i = 0; i < checkboxes.leng th; i++) {
if (checkboxes[i].checked) {
document.getEle mentById('oTBod y0').deleteRow( i + 1);
removevalue(for m);
}
}
}

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
1825
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 mean to send the matrix to server side. =======================================================
2
5143
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? Also, how can I associate all the attributes and their values of a particular element to the Name & Value columns of a datatable - to read into a datatable as well as write from the datatable to the xml element? Any help will be greatly...
5
36880
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 code behind. However I am not able to do this at all, I am going about this wrong, I think and need guideance. If this was just straight HTML I would do this: <table> <tr><td>field 1</td><td>value 1 set by code behind</td></tr>
5
2400
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 screaming fast? function sortTable(id, col, rev) { // Get the table or table section to sort. var tblEl = document.getElementById(id);
1
1601
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 EventArgs) Dim imgStream as Stream = Add3Image.PostedFile.InputStream Dim imgLen as Integer = Add3Image.PostedFile.ContentLength Dim imgType as String = Add3Image.PostedFile.ContentType If Not imgStream Is Nothing And imgLen > 0 And (imgType =
4
2040
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 inner joined to ChildTable on ParentTable.ParentID =
0
2232
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. it urgent i submit this application. when it runs it gives: this OdbcTransaction has completed,it no longer usable. thx toyin here is the code Sub ProcessAllSynchOperations() Dim sSourceURL, sWebSiteIP As String Dim...
3
293
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 works. 1. initTreeView(TreeNode N) creates a new "temp" table to hold the children for each node. Each time the table is created it has the same name "temp". Why doesn't the table just get over written each time? 2. In the foreach (DataRow r3...
3
1556
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
9511
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10195
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10136
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9016
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5415
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5548
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4090
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3695
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2906
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.