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

help me please

1
[HTML]
<html>
<head>
<title>Me</title>

<link href="style.css" rel="stylesheet" type="text/css">

<script language="javascript">
rowid = 1;
doc = document;

function delRow (elemToDel) {
if (!elemToDel) return;
elemToDel.parentNode.removeChild(elemToDel);
}

function addRowTo(id) {
var tbl = doc.getElementById(id);
var newrow = doc.createElement("TR");
var newcol , newinput;

//rowid
newcol = doc.createElement("TD");
newcol.width = 30;
newcol.title = "ReadOnly";
newcol.align = "center";
newinput = doc.createElement("input");
newinput.name = "rowid"+rowid;
newinput.size = 2;
newinput.value = ""+rowid;
newinput.readonly = "readonly";
newcol.appendChild(newinput);
newrow.appendChild(newcol);

//hardware
newcol = doc.createElement("TD");
newcol.width = 150;
newcol.align = "center";
newinput = doc.createElement("input");
newinput.name = "hardware"+rowid;
newinput.size = 30;
newinput.value = "";
newcol.appendChild(newinput);
newrow.appendChild(newcol);

//brand
newcol = doc.createElement("TD");
newcol.width = 150;
newcol.align = "center";
newinput = doc.createElement("input");
newinput.name = "brand"+rowid;
newinput.size = 30;
newinput.value = "";
newcol.appendChild(newinput);
newrow.appendChild(newcol);

//price
newcol = doc.createElement("TD");
newcol.width = 150;
newcol.align = "center";
newinput = doc.createElement("input");
newinput.id = "price"+rowid;
newinput.name = "price"+rowid;
newinput.size = 30;
newinput.value = "";
newcol.appendChild(newinput);
newrow.appendChild(newcol);

//tool
newcol = doc.createElement("TD");
newcol.width = 20;
newcol.align = "center";
newinput = doc.createElement("input");
newinput.setAttribute("type","image");
newinput.name = "destroy"+rowid;
newinput.src="i_delete.gif";
newinput.onclick=new Function ("delRow(document.getElementById('row"+rowid+"')); ");
newcol.appendChild(newinput);
newrow.appendChild(newcol);

tbl.appendChild(newrow);
rowid++;

//document.main.hardware.value = '';
//document.main.brand.value = '';
//document.main.end.value = '';

//document.main.hardware.focus();
}
</script>

</head>
<body>
<form name="main" method='post'>
<table id="tbl1" width="800" border="1" cellspacing="1" cellpadding="2" style="border-collapse:collapse;">
<tbody id="tbl1body">
<tr bgcolor="#94D5FF" align="center">
<td width="30"><b>ID</b></td>
<td width="150"><b>Hardware</b></td>
<td width="150"><b>Brand</b></td>
<td width="150"><b>Price</b></td>
<td width="20"><a href="#" onClick="addRowTo('tbl1body')"><img border=0 src="i_add.gif"></a></td>
</tr>
<tr>
<td><input type='hidden' name='rowid' size=20 maxlength=200 value=""></td>
<td><input type='hidden' name='hardware' size=20 maxlength=200 value=""></td>
<td><input type='hidden' name='brand' size=20 maxlength=200 value=""></td>
<td><input type='hidden' name='price' size=20 maxlength=200 value=""></td>
</tr>
</table>
</form>
<table id="tbl1" width="800" border="1" cellspacing="1" cellpadding="2" style="border-collapse:collapse;">
<tbody id="tbl1body">
<tr bgcolor="#94D5FF" align="center">
<td>
Sum Price :
</td>
</tr>
</table>
</html>
[/HTML]
Please use the code tags from now on - iam_clint


add row is good but remove row not good it remove all row
and i need get sum price value
Dec 14 '06 #1
1 1369
acoder
16,027 Expert Mod 8TB
...
function delRow (elemToDel) {
if (!elemToDel) return;
elemToDel.parentNode.removeChild(elemToDel);
}

function addRowTo(id) {
var tbl = doc.getElementById(id);
var newrow = doc.createElement("TR");
var newcol , newinput;

//rowid
newcol = doc.createElement("TD");
newcol.width = 30;
newcol.title = "ReadOnly";
newcol.align = "center";
newinput = doc.createElement("input");
newinput.name = "rowid"+rowid;
newinput.size = 2;
newinput.value = ""+rowid;
newinput.readonly = "readonly";
newcol.appendChild(newinput);
newrow.appendChild(newcol);
...

//tool
newcol = doc.createElement("TD");
newcol.width = 20;
newcol.align = "center";
newinput = doc.createElement("input");
newinput.setAttribute("type","image");
newinput.name = "destroy"+rowid;
newinput.src="i_delete.gif";
newinput.onclick=new Function ("delRow(document.getElementById('row"+rowid+"')); ");
newcol.appendChild(newinput);
newrow.appendChild(newcol);

tbl.appendChild(newrow);
rowid++;

//document.main.hardware.value = '';
//document.main.brand.value = '';
//document.main.end.value = '';

//document.main.hardware.focus();
}
</script>

</head>
<body>
<form name="main" method='post'>
<table id="tbl1" width="800" border="1" cellspacing="1" cellpadding="2" style="border-collapse:collapse;">
<tbody id="tbl1body">
<tr bgcolor="#94D5FF" align="center">
<td width="30"><b>ID</b></td>
<td width="150"><b>Hardware</b></td>
<td width="150"><b>Brand</b></td>
<td width="150"><b>Price</b></td>
<td width="20"><a href="#" onClick="addRowTo('tbl1body')"><img border=0 src="i_add.gif"></a></td>
</tr>
<tr>
<td><input type='hidden' name='rowid' size=20 maxlength=200 value=""></td>
<td><input type='hidden' name='hardware' size=20 maxlength=200 value=""></td>
<td><input type='hidden' name='brand' size=20 maxlength=200 value=""></td>
<td><input type='hidden' name='price' size=20 maxlength=200 value=""></td>
</tr>
</table>
</form>

<table id="tbl1" width="800" border="1" cellspacing="1" cellpadding="2" style="border-collapse:collapse;">
<tbody id="tbl1body">
<tr bgcolor="#94D5FF" align="center">
<td>
Sum Price :
</td>
</tr>
</table>
</html>


add row is good but remove row not good it remove all row
and i need get sum price value
Maybe you need to set the id of each as rowid rather than use an input field with a value of rowid.

For the sum price value, keep a variable and store the total. When you delete, update this value. Also, have an onchange handler to update the value, but you need to remove the old value first. What I do is to store the values in an array and sum the totals on each change.
Dec 15 '06 #2

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

Similar topics

3
by: laurie | last post by:
Hi all, I'm trying to help out a friend who has inherited a client with a PHP shopping cart application. Neither of us know PHP, but I've been muddling my way through, trying to get these old...
1
by: the_proud_family | last post by:
HELP ME PLEASE!! my email is the_proud_family@yahoo.com I can't get the ball to go up right side and then I need it to turn around and keep turning until velocity=0 I have been at it for the ...
0
by: Kurt Watson | last post by:
I’m having a different kind of problem with Hotmail when I sign in it says, "Web Browser Software Limitations Your Current Software Will Limit Your Ability to Use Hotmail You are using a web...
12
by: Christo | last post by:
borland c++ 5.01 character constant must be one or two characters long get this when compiling my first c++ program can anyone out there help? it is highlighting this line as the problem ...
7
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: {////<<head> <title>IIBO Submit Page</title>...
5
by: Craig Keightley | last post by:
Please help, i have attached my page which worksin IE but i cannnot get the drop down menu to fucntion in firefox. Any one have any ideas why? Many Thanks Craig ...
17
by: JT | last post by:
Help me the following C++ question: Write a program to help a local bookshop automate its billing system. The program should do the following: (a)Let the user enter the ISBN, the system will...
7
by: tyler_durden | last post by:
thanks a lot for all your help..I'm really appreciated... with all the help I've been getting in forums I've been able to continue my program and it's almost done, but I'm having a big problem that...
23
by: Jason | last post by:
Hi, I was wondering if any could point me to an example or give me ideas on how to dynamically create a form based on a database table? So, I would have a table designed to tell my application...
2
by: =?Utf-8?B?U2NvdHRSYWREZXY=?= | last post by:
I'm creating a doc project for my c# program. I've done this before but this time sonething is wrong. I build my doc project and is succeeds but when I open the help file, there is no documentation...
0
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
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...
1
isladogs
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...
0
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...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
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....
0
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 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.