File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes Add and Edit a row Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Add and Edit a row" Watch "Add and Edit a row" New topic
Author

Add and Edit a row

Chitti pokala
Ranch Hand

Joined: Jan 11, 2005
Posts: 46
Hi
I have a parent window where I can add, edit or delete a row from a table.
If I click add button it should open a popup window where I can add a row to the table in the parent window. If I click the edit button the row in the child pop up window should populate with the selected row values from the parent window. If I click save on child window the value from the child window should be added to the table in the parent window.

I am not able to get the add values from the child to parent window.

Please let me know, how to do this.

Thanks in Advance.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
You should look into

createElement
setAttribute
createTextNode

for adding rows

and

arrayCells = document.getElementById("rowID").getElementsByTagName("td");

var cell0HTML = arrayCells[0].innerHTML;

for editing a row.
Chitti pokala
Ranch Hand

Joined: Jan 11, 2005
Posts: 46
please let me know how to edit a row.

Thanks
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
The code I posted above shows you how to do that.. It puts the cell contents into an array.

Eric
Chitti pokala
Ranch Hand

Joined: Jan 11, 2005
Posts: 46
I tried with this but, I am not able to get the values from parent window to the child window.
Chitti pokala
Ranch Hand

Joined: Jan 11, 2005
Posts: 46
Please help me with editing a row. I would appreciate your help.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
What is the code that you are using that is not working?

Eric
Chitti pokala
Ranch Hand

Joined: Jan 11, 2005
Posts: 46
Hi
I would like to know how to I include colors to the alternate rows....
I did it with using style, but I am not getting the color.

Also, I would like to know how to include header for the table...


--------------------------------------------------------------------------
style
.odd{background-color: white;}
.even{background-color: gray;}
style
script type="text/javascript"
function alternate(id){
if(document.getElementsByTagName){
var table = document.getElementById(id);
var rows = table.getElementsByTagName("tr");
for(i = 0; i < rows.length; i++){
//manipulate rows
if(i % 2 == 0){
rows[i].className = "even";
}else{
rows[i].className = "odd";
}
}
}
}
function SendInfo(){
var txtVal = document.formPop.popupoldPart.value;
var txtVal1 = document.formPop.popupnewPart.value;

var tbl = window.opener.document.getElementById('tblSample1');
var lastRow = tbl.rows.length;
// if there's no header row in the table, then iteration = lastRow + 1
var iteration = lastRow;
var row = tbl.insertRow(lastRow);

// left cell
var cellLeft = row.insertCell(0);
var textNode1 = window.opener.document.createElement('input');
textNode1.setAttribute('type', 'image');
textNode1.setAttribute('name', 'Edit' + iteration);
textNode1.setAttribute('id', 'Edit' + iteration);
textNode1.setAttribute('width', '20');
textNode1.setAttribute('height', '20');
textNode1.setAttribute('src', 'editRow.gif');
cellLeft.appendChild(textNode1);

var cellLeft = row.insertCell(1);
var textNode1 = window.opener.document.createElement('input');
textNode1.setAttribute('type', 'image');
textNode1.setAttribute('name', 'Edit' + iteration);
textNode1.setAttribute('id', 'Edit' + iteration);
textNode1.setAttribute('width', '20');
textNode1.setAttribute('height', '20');
textNode1.setAttribute('src', 'deleteRow.gif');
cellLeft.appendChild(textNode1);

var cellMiddle = row.insertCell(2);
var textNode = window.opener.document.createElement('input');
textNode.setAttribute('type', 'text');
textNode.setAttribute('name', 'txtRow' + iteration);
textNode.setAttribute('id', 'txtRow' + iteration);
textNode.setAttribute('size', '40');
textNode.setAttribute('value', txtVal);
cellMiddle.appendChild(textNode);

// right cell
var cellRight = row.insertCell(3);
var el = window.opener.document.createElement('input');
el.setAttribute('type', 'text');
el.setAttribute('name', 'txtRow' + iteration);
el.setAttribute('id', 'txtRow' + iteration);
el.setAttribute('size', '40');
el.setAttribute('value', txtVal1);
cellRight.appendChild(el);

// window.opener.document.form1.text1.value = txtVal;
//window.opener.document.form1.text2.value = txtVal1;
window.close();
}




form name="formPop"
Part Number Old: input type="text" name="popupoldPart" Part Number New:input type="text" name="popupnewPart"
input type="button" name="button" value="OK"
click="SendInfo()"
---------------------------------------------------------------------------
Thanks in Advance.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Add and Edit a row