Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
|
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 5th, 2004, 06:16 AM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 363
Thanks: 0
Thanked 1 Time in 1 Post
Default insert child

I have a table with header row and body rows. Body rows are named as "tr1" When i click a button, it asks the user to delete particular row. I did like this

<input type="button" value="Delete" onclick="delRow('tr1')">

<script language="javascript">
function delRow(_id){
//window.prompt to get the number from user
    var _elm=document.getElementById(_id);
    var _par=_elm.parentNode;
    var _remid=_par.removeChild(_elm);
}
</script>


But it always deletes the first row(tr1(0)) only.
How can i delete specific(tr1(2)).

And, how can i insert new child. I tried,

 _par.appendChild(_elm)

But it overwrites existing. Coz already tr1 is there.
How can i insert new child with the same name as 'tr1'

Thanx in advance


 
Old October 5th, 2004, 07:15 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Surely this is a topic for the Web forum?
Seems like you're not defining the row clearly enough, if they all have the same name and not id then your code will not work as intended. Try to pass the row as a parameter, not the string value 'tr1'. If you show an example row where the button is I can show you the code.

--

Joe
 
Old October 5th, 2004, 08:11 PM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 363
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hello, thank you for reply. Here is my table


<form name="frm1">
<table align="center" cellpadding="3" cellspacing="0" border="1" id=tab1 name=tab1>
    <thead>
    <tr>
        <th>Opr. No</th>
        <th>Pay Type</th>
        <th>Qty</th>
        <th>OT(Y/N)</th>
        <th>Action</th>
    </tr>
    </thead>
    <tbody name="tb1" id="tb1">
    <tr name="tr1" id="tr1" align="center">
        <td>11</th>
        <td>P</th>
        <td>500</th>
        <td>N</th>
        <td>0</th>
    </tr>
    <tr name="tr1" id="tr1" align="center">
        <td>06</th>
        <td>P</th>
        <td>600</th>
        <td>N</th>
        <td>0</th>
    </tr>
    <tr name="tr1" id="tr1" align="center">
        <td>09</th>
        <td>T</th>
        <td>0</th>
        <td>Y</th>
        <td>2</th>
    </tr>
    </tbody>
</table>
<br><br>
<input type="button" value="Delete" onclick="delRow('tr1')">
<input type="button" value="Add" onclick="addrow('tr1')">
</form>



My aim is to design a grid layout for data entry. The table initially contains one row with textboxes. If the user click to add new record, new row should append to the existing table with textboxes.
Is there any other way to do this?

----------
Rajani

 
Old October 5th, 2004, 11:15 PM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 363
Thanks: 0
Thanked 1 Time in 1 Post
Default

Ok,

  I got it. Thanx for u r affort.



-----
Rajani






Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert Into Parent Child Table prasanta2expert Access VBA 3 November 8th, 2007 11:18 AM
Child Help. lafilip XSLT 6 November 20th, 2006 06:53 PM
Opening MDI Child on Button Click of MDI Child Sachin Shinde Visual Studio 2005 0 June 8th, 2006 05:05 AM
trigger to insert current date on insert kev_79 SQL Server 2000 3 January 23rd, 2006 05:58 PM
MDI Child sidneyfuerte VB How-To 4 July 18th, 2004 08:11 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.