Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sessions

Status
Not open for further replies.

LeoLionHeart

Programmer
Joined
Apr 4, 2006
Messages
45
Location
GB
Hi I was wondering if you could help.

I have a web form with two html buttons and two text boxes. The buttons open up a child window using the following code:

Code:
function OpenNew()
{
window.open('SecSearch.aspx','mywindow','width=360,height=200');

}

The form that is open is a search form which displays information in a hidden input box and this value then is transferred back to the parent form, such as:

Code:
function Populate()
{
var name=document.getElementById("savelistIndex").value;
opener.document.getElementById("txtSec").value = name;
window.close();
}

However, the getElementById("txtSec") could change to ("txtHR"). How do I determine which button was pressed in the first place e.g a session variable in javascript so that I can make the getElementById variable.

Any help would be appreciated.

Thanks

Leo.
 
One way would be to first set the ID of the button that called the function into a hidden form field. Read that value from your popup window and use it to set the name of the field to write back to.

Code:
function Populate()
{
[COLOR=red]var fldName=document.getElementById('hdnBtnName').value;[/color]
var name=document.getElementById("savelistIndex").value;
opener.document.getElementById("[COLOR=red]'"+fldName+"'[/color]").value = name;
window.close();
}



[COLOR=blue]It's hard to think outside the box when I'm trapped in a cubicle.[/color]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top