0

I want to open new window from existing form.When I am clicking on new window in form then new form should open with results of value entered,but new window form is opening with main page,not able to get text box value from parent form.

How to call textfield input value in popup window from parent window using javascript?

//currently I'm using following code:
<script type="text/javascript">
function pop_up5() {
  var l_url=window.opener.document.getElementById("name").value;
  window.open(l_url,'''','scrollbars=yes,resizable=no,width=550,height=400');
}
</script>
1
  • 1
    Have you tried passing querystring fields..? Commented Dec 20, 2012 at 7:27

2 Answers 2

2

Assign window.open() to a variable so you can access it's elements.

<form>
    <input type="textbox" id="txt" />
    <input type="button" id="btn" value="Open window" />
</form>

<script>
document.getElementById('btn').onclick = function(){
    var myWindow = window.open();
    myWindow.document.body.innerHTML = document.getElementById('txt').value;
};
</script>
Sign up to request clarification or add additional context in comments.

Comments

1

Suppose your text field's id is myTextField, whatever you named it. if it has no id, set a id for it. then, in the popup window, you can use JavaScript parent.document.getElementById('myTextField').value to get the value of the textfield.

2 Comments

@muthun kumaran: now the problem is in eclipse i can able to store the child window values in database but in chrome and firefox nt able to store those values??
can not understand your problem, do you mean the code doesn't work in chrome or firefox? i'm sorry, i made a mistake. should use window.opener instead of parent. so the code will be window.opener.document.getElementById('myTextField').value

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.