This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes How to rendar data from new window to  old window through window.focus() ? Or any other way. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "How to rendar data from new window to  old window through window.focus() ? Or any other way." Watch "How to rendar data from new window to  old window through window.focus() ? Or any other way." New topic
Author

How to rendar data from new window to old window through window.focus() ? Or any other way.

Abhra Kar
Ranch Hand

Joined: May 22, 2008
Posts: 122
Hi
I have a jsp named index.jsp---------
<html>
<head>
<script type="text/javascript">
function myfunc(){
var fname=document.getElementById("fname");
var lname=document.getElementById("lname");
window.open("credential.jsp?fname="+fname.value+"&lname="+lname.value,"mywindow","width=200,height=200");
}
</script>
</head>
<body>

<form name="form1">
First Name:
<input type="text" name="fname" id="fname" />
Last Name:
<input type="text" name="lname" id="lname" />
<input type="button" value="click here" onclick="myfunc()" />
</form>
</body>
</html>


Now flow goes to credential.jsp----------
<%@ page isELIgnored="false" %>
<html>
<head>
<script type="text/javascript">
function myfunc1(){
var origWin = window.opener ;
if (origWin != null) {
origWin.document.body.style.backgroundColor = "#a1b2c3" ;
origWin.focus() ;
}
}
</script>
</head>
<body>
<form>
<input type="text" name="credential" value="${param.fname}" />
<input type="hidden" name="lastname" value="${param.lname}" />
<input type="password" name="password"/>
<input type="submit" value="click it" onclick="myfunc1()" />
</form>
</body>
</html>


From credential.jsp flow is coming back to index.jsp,but I want the data I have filled in input field I will append in index.jsp in a text area .
Please suggest me the way(with window.focus() or without window .focus())
Thanks in advance.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
window.opener is the way to do it. If you debug window.opener is it null? Are you getting errors?

Eric
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to rendar data from new window to old window through window.focus() ? Or any other way.
 
Similar Threads
How to remove Textbox Element using DOM in HTML
recod is not inserting in mysql databse
Is onSubmit() mandatory to write when SimpleFormController is used?
How to get back in old window from a new window
can we put HTML input tag with in <form:form> </form:form>?