pavan
pavan

Reputation: 1

How to set parent window values to child window?

How to set parent window values to child window?

In parent window i have few textboxes. When i enter some values and click on button i need to get those values in child window. I am using HTML and javascript. I need this in javascript or jquery. Please help me. Thanks in advance.

Upvotes: 0

Views: 3366

Answers (1)

Edgar Villegas Alvarado
Edgar Villegas Alvarado

Reputation: 18354

In your parent window, you should have a function:

//parent window
function getParentValue(){
  return $("#textbox").val();
}

You can call this function in your child window:

//child window

var parentValue = window.opener.getParentValue();
alert(parentValue);

This works because functions are public by default (not like vars)

Hope this helps. Cheers

Upvotes: 2

Related Questions