Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

updating form field in popup from parent window SOMETIMES works 1

Status
Not open for further replies.

janelange

Technical User
Jun 12, 2003
45
0
0
US
Here's what I'm trying to do:

--Create a popup window from the main window.
--Populate a text input field in a form on the popup with a value passed from the main window.

Here's my function, which is called by an onClick event in the main document:

Code:
function defineSelectionLimit(input){
	var newwindow=window.open('inputtest.php', 'newwindow', 'width=550,height=550top=666,left=666');
	
	newwindow.document.formID.endLine.value=input;
}

Here's the link in the main document that calls the function
Code:
<a href="#" onClick="defineSelectionLimit('$row[1]');"> $line  </a>


Here's the code from "inputtest.php"
Code:
<Form NAME="formID" type="submit">
<Input TYPE="text" NAME="endLine">
</Form>

The code works fine some of the time. However, sometimes I get the error message 'document.formID.endline is Null or not an Object'. There doesn't seem to be any pattern to the occurance of these errors.

I've been testing with I.E. and Mozilla. The code never works in Mozilla.

Ideas?
Thanks--
JL
 
Well, the form field doesn't exist until the popup window loads it. So it depends on how fast the page loads. Try using this in the main window:

Code:
var lastInput;
function defineSelectionLimit(input){
    var newwindow=window.open('inputtest.php', 'newwindow', 'width=550,height=550top=666,left=666');

    lastInput = input;
}
And add this to the popup window:
Code:
<html>
<head>
<script>
function body_onload(){
    document.formID.endLine.value=opener.lastInput;
}
</script>
<body onload="body_onload()">

Adam
 
Thanks...this works...

What if I want to load another value to this popup window that I've already opened, without reloading the popup?

I suppose I can use an onClick event like the one I wrote earlier, but I'll need to figure out how to determine if the popup window exists.


JL
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top