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!

Help! is null or not an object in IE

Status
Not open for further replies.

beckwiga

Programmer
Mar 30, 2005
70
0
0
Hello all. I need an extra set of eyes if someone is willing to have a look.

'targetitem' is null or not an object

in IE when I view a page I am developing. I can't figure out why I'm getting it. The JS works fine in FF, altough visually my page needs work is FF.


Instead of posting my code in here, please view page source of both pages.

On the LB_XPAND_LOGGED.php page, find the Convert link under Find a Spot. When clicked, calls convert.shtml.

My problem is after I use JS to convert a latitude and longitude (or fill in some bogus values), when I click Return to Lat and Long, I am not able to return a value back to my original page. I get the null object error. I want the Lat and Long from the popup page to populate back to the original php page.

Any one see the problem?? Like I mentioned, it works in FF. I can't figure out what IE is telling me.

thanks in advance.

beckwiga
 
The orthodox way would give more assurance.
[tt]
function select_item(item)
{
[red]//[/red]targetitem.value = item;
[blue]if (window.opener && !window.opener.closed) {
window.opener.document.forms[0].point_lat=item;
}[/blue]
window.close();
return false;
}
[/tt]
 
Hi tsuji, I really appreciate your response.

I'm still learning javascript, is the above code saying:

If the window that opens exists and is not closed then

set the field named point_lat on the original opening page (form 0) to item?

If this is true, is there any need for my other onClick expressions in lb_expand_logged.php?

onClick='targetitem = document.forms[0].point_lat; dataitem = window.open("convert.shtml", "dataitem", "toolbar=yes,menubar=yes,scrollbars=yes"); dataitem.targetitem = targetitem'>

Following your above suggestion, I no longer receive my Is Null or Not an Object error, however, no text is returned from the LatDecimalDegrees field (in convert.shtml) to the point_lat field (in lb_xpand_logged.php). I think my form numbers and field names are correct, but I'm not positive.

Can you offer any suggestions on how I can troubleshoot this? I am new to JS and I have the most trouble understand JS syntax and troubleshooting IE errors.
 
>onClick='targetitem = document.forms[0].point_lat; dataitem = window.open("convert.shtml", "dataitem", "toolbar=yes,menubar=yes,scrollbars=yes"); dataitem.targetitem = targetitem'>

I would say you don't need variable targetitem any more (if it is not used elsewhere in the same page just by misuse of the scope.) The variable dataitem you may keep it. But probably sparing it would be just fine.

[tt]onClick='window.open("convert.shtml", "dataitem", "toolbar=yes,menubar=yes,scrollbars=yes");'>[/tt]
 
Great, thanks tsuji. I just figured it out. I named my form on the opening page and referenced it by name. I also had to add a few .value to my code.

function select_item(item)
{
//targetitem.value = item;
//alert(item.value);

if (window.opener && !window.opener.closed) {
window.opener.document.forms['latlongform'].point_lat.value=item.value;
}
window.close();
return false;
}


I found this explanation helpful:

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top