views:

100

answers:

2

I am developing a website in which I need to send a value from parent window to child window.

Is it possible via the URL ?

For example: I have this line in parent window

<tr ondblclick="fopenclaim(69856984);" id =trackrow>';

function fopenclaim(number)
{
  window.open('https://www.sample.com/ClaimsOnline/','claimform','width=800,height=800');
}

in that https://www.sample.com/ClaimsOnline/ I have a textbox named tracknumber. I want to fill the value of this number in to that text box.. Please help me to find out . Thanks in advance

A: 

You could pass the claim number in the Querystring and load it from the Querystring collection and then set the value of the textbox in the target page.

function fopenclaim(number)
{
  window.open('https://www.sample.com/ClaimsOnline/myPage.asp?claimNum=' + number.toString(), 'claimform', 'width=800, height=800');
}

You have not mentioned the framework you are using (ASP/ASP.NET/PHP/JSP, etc) so I won't elaborate on how to retrieve the Querystring value from the Request object.

If you want to use JS on the target page to retrieve the Querystring value, then you can use retrieve the window.location value and perform a string search to find the querystring value of the parameter("claimNum"). Here's an example.

Cerebrus
A: 

I'm not sure of about a javascript only implementation but if you have server side scripting available this would be trivial.

window.open('https://www.sample.com/ClaimsOnline/?foo=bar','claimform','width=800,height=800');

For example in PHP this would be

Then the $_GET['foo'] variable will contain the value bar which you can then echo out to your child page.

neilc