-
Can Anyone please help me to solve
Hi all,
I am facing some problem while populating value from a child window to parent window.
I have a main html page, that can generate dynamic rows. If I click on a link from dynamically created rows, should display a popup window.
Popup window will display some record with a link. If I click on the link from the popup window, the value should be filled in the main (parent) html page (Dynamically created fields place).
Here is my code....
main.html
---------
<html>
<head>
<title>InsertTable Row </title>
<script language="javascript">
var gRowId = 2;
function delRow(button)
{
var row = button.parentNode.parentNode;
var tbody = document.getElementById('table1').getElementsByTagName('tbody')[0];
tbody.removeChild(row);
}
function addRow()
{
var tbody = document.getElementById('table1').getElementsByTagName('tbody')[0];
var gRowId1 = gRowId;
var row = document.createElement('TR');
var cell1 = document.createElement('TD');
var cell2 = document.createElement('TD');
var inp1 = document.createElement('INPUT');
var inp2 = document.createElement('INPUT');
inp1.setAttribute('type','text');
inp1.setAttribute('name','usertxt'+gRowId1);
var anc = document.createElement("a");
anc.href="#"
anc.onclick= function() {
window.caller = document.getElementById("usertxt" + gRowId1)
var cal = window.open('C:/del4.html','search','resizable=no,left=300,top=200,width=350,height=300');
if (!cal.opener) cal.opener = self;
return false
}
var img = document.createElement('img');
img.src = 'C:/cal.jpg';
img.border='0';
anc.appendChild(img);
inp2.setAttribute('type','button');
cell1.innerHTML = gRowId;
cell2.appendChild(inp1);
cell2.appendChild(anc);
row.appendChild(cell1);
row.appendChild(cell2);
tbody.appendChild(row);
gRowId++;
}
</script>
</head>
<body>
<form name="myform" method="post">
<table id="table1">
<tbody>
<tr>
<th>ID</th><th>Data</th>
</tr>
<tr>
<td>1</td>
<td><input name="usertxt" type=text value="Original Row"><a href="#" onClick="window.caller = document.forms[0].usertxt;cal = window.open('C:/del4.html','search','resizable=no,left=300,top=200,width=350,height=300'); if (!cal.opener) cal.opener = self; return false"><img src = "C:/cal.jpg" border="0" ></a></td>
</tr>
</tbody>
</table>
<input type="button" value="Insert Row" onClick="addRow();">
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>
========================
child window
del4.html
<HTML>
<HEAD>
<TITLE> Child window </TITLE>
</HEAD>
<BODY>
<form>
<TABLE>
<TR>
<td width=5% align=center><a href="#" onClick="opener.caller.value='3000';window.close();">3000</a></td>
</TR>
<TR>
<td width=5% align=center><a href="#" onClick="opener.caller.value='4000';window.close();">4000</a></td>
</TR>
</TABLE>
</form>
</BODY>
</HTML>
Please give me a solution for this problem
Thanks
-
-
Add this part (in red) just after the assignment of the name attribute:
inp1.setAttribute('type','text');
inp1.setAttribute('name','usertxt'+gRowId1);
inp1.id='usertxt'+gRowId1;
-
-
Hi John,
Thanks for your help. It's working fine. Excellent!!!
Skumar
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks