stpaulmn
05-04-2006, 08:55 AM
My code to add rows to a table:
function addRow(){
var tbody = document.getElementById("table1").getElementsByTagName("tbody")[0];
var row = document.createElement("TR");
var cell1 = document.createElement("TD");
cell1.innerHTML = "MatterID";
//cell1.innerHTML = gRowId;
var cell2 = document.createElement("TD");
var inp1 = document.createElement("INPUT");
inp1.setAttribute("type","text");
inp1.setAttribute("value","");
inp1.setAttribute("size","60");
inp1.setAttribute('id','matterId');
inp1.setAttribute('name','matterId');
cell2.appendChild(inp1);
var cell3 = document.createElement('TD');
var inp2 = document.createElement('INPUT');
inp2.setAttribute('type','button');
inp2.setAttribute('value','LookUp');
inp2.onclick=function(){popupOpenSearchDialog();}
cell3.appendChild(inp2);
var cell5 = document.createElement('TD');
var inp4 = document.createElement('INPUT');
inp4.setAttribute('type','button');
inp4.setAttribute('value','Delete');
inp4.onclick=function(){deleteRow(this);}
cell5.appendChild(inp4);
row.appendChild(cell1);
row.appendChild(cell2);
row.appendChild(cell3);
row.appendChild(cell5);
tbody.appendChild(row);
//alert(row.innerHTML);
gRowId++;
cell1 = null;
cell2 = null;
cell3 = null;
cell4 = null;
row = null;
newRow = null;
tbody = null;
}
The popupOpenSearchDialog() will open a popup where i do a search.
There is a radio button, on click of which the selected row value should be inserted into the main window's MATTERID INPUT TEXT BOX. IT is only doing for the first time/first row..
Looks like it is losing the reference to the text box once the pop up is opened and I am using the following code to write the value into the text box in the main window frm the popup
Function in the popup to write into the text box of the main window:
function loadSelectedValue(matterId,matterName){
alert("matterId====" + matterId);
alert("matterName====" + matterName);
window.opener.document.forms[0].matterId.value = "(" + matterId + ")" + " -" + matterName;
alert("matteridname===" + window.opener.document.forms[0].matterId.value);
window.opener.focus();
window.close();
}
When i alert the values here in the popup all the values are dispayed correctly. I think I am not using the right way to put the value into the main window's text box.
Thankyou fo ryour help in advance
function addRow(){
var tbody = document.getElementById("table1").getElementsByTagName("tbody")[0];
var row = document.createElement("TR");
var cell1 = document.createElement("TD");
cell1.innerHTML = "MatterID";
//cell1.innerHTML = gRowId;
var cell2 = document.createElement("TD");
var inp1 = document.createElement("INPUT");
inp1.setAttribute("type","text");
inp1.setAttribute("value","");
inp1.setAttribute("size","60");
inp1.setAttribute('id','matterId');
inp1.setAttribute('name','matterId');
cell2.appendChild(inp1);
var cell3 = document.createElement('TD');
var inp2 = document.createElement('INPUT');
inp2.setAttribute('type','button');
inp2.setAttribute('value','LookUp');
inp2.onclick=function(){popupOpenSearchDialog();}
cell3.appendChild(inp2);
var cell5 = document.createElement('TD');
var inp4 = document.createElement('INPUT');
inp4.setAttribute('type','button');
inp4.setAttribute('value','Delete');
inp4.onclick=function(){deleteRow(this);}
cell5.appendChild(inp4);
row.appendChild(cell1);
row.appendChild(cell2);
row.appendChild(cell3);
row.appendChild(cell5);
tbody.appendChild(row);
//alert(row.innerHTML);
gRowId++;
cell1 = null;
cell2 = null;
cell3 = null;
cell4 = null;
row = null;
newRow = null;
tbody = null;
}
The popupOpenSearchDialog() will open a popup where i do a search.
There is a radio button, on click of which the selected row value should be inserted into the main window's MATTERID INPUT TEXT BOX. IT is only doing for the first time/first row..
Looks like it is losing the reference to the text box once the pop up is opened and I am using the following code to write the value into the text box in the main window frm the popup
Function in the popup to write into the text box of the main window:
function loadSelectedValue(matterId,matterName){
alert("matterId====" + matterId);
alert("matterName====" + matterName);
window.opener.document.forms[0].matterId.value = "(" + matterId + ")" + " -" + matterName;
alert("matteridname===" + window.opener.document.forms[0].matterId.value);
window.opener.focus();
window.close();
}
When i alert the values here in the popup all the values are dispayed correctly. I think I am not using the right way to put the value into the main window's text box.
Thankyou fo ryour help in advance