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>
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>
Share
Improve this question
edited Dec 20, 2012 at 7:24
Jan Hančič
53.9k17 gold badges98 silver badges101 bronze badges
asked Dec 20, 2012 at 7:20
varadarajvaradaraj
31 gold badge1 silver badge6 bronze badges
1
- 1 Have you tried passing querystring fields..? – Anujith Commented Dec 20, 2012 at 7:27
2 Answers
Reset to default 2Assign 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>
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.