• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Add and Edit a row

 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
please let me know how to edit a row.

Thanks
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The code I posted above shows you how to do that.. It puts the cell contents into an array.

Eric
 
Chitti pokala
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried with this but, I am not able to get the values from parent window to the child window.
 
Chitti pokala
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please help me with editing a row. I would appreciate your help.
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the code that you are using that is not working?

Eric
 
Chitti pokala
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Slime does not pay. Always keep your tiny ad dry.
New web page for Paul's Rocket Mass Heaters movies
https://coderanch.com/t/785239/web-page-Paul-Rocket-Mass
reply
    Bookmark Topic Watch Topic
  • New Topic