I am having trouble passing text from a webpage in a popup window to the parent webpage. Both webpages are ASP .NET but I am using JavaScript to pass the text. Since the problem I am having relates to the JavaScript portion of the code, I decided to post it here.
I am using Visual Studio .NET 2005 as the IDE. The computer that I am developing on has Windows .NET 2003 Server and .NET Framework 2.0 .
There are 2 webpages:
newrequest.aspx and searchdatabasedialog.aspx
There is a button on the newrequest.aspx webpage that brings up the searchdatabasedialog.aspx webpage in a popup window.
The user can search Locations based on criteria that he or she enters in the search form.
Once the search is complete, the webpage displays the search results on the same page in the same popup
window (the original form's fields get hidden).
The columns displayed and their format (i.e. html or plain text) are as follows:
Location Name Location Alpha Location City Location State Location Office
Html link text text text text
Clicking on the Location Name hyperlink should close the search results webpage and pass the Location Name back to the newrequest.aspx webpage (the Locationname textbox on the newrequest.aspx webpage should get populated.
I have the following JavaScript function defined in the searchdatabasedialog.aspx webpage.
function message(alpha,locname,address1,address2,city,state,zip) {
opener.document.forms[frmNewRequest].elements[txtLocationName].value = locname;
self.close() ;
}
Then, I have the following JavaScript in the Location Name html links in the search results.
<a href=”#” OnClick=”javascript:message(‘’,location_name_returned_from_the_database, ’’,’’,’’,’’,’’) “ ;
I get the following JavaScript error when I click on one of the HTML links returned.
'frmNewRequest is undefined’.
There is a form with id=”frmNewRequest” defined on the newrequest.aspx webpage. I have no clue as to why
it is not finding the 'frmNewRequest' from on the newrequest.aspx . The spelling and casing are correct.
Can anyone spot a problem in the code above? I would appreciate any help.
Thanks.
Saad
I am using Visual Studio .NET 2005 as the IDE. The computer that I am developing on has Windows .NET 2003 Server and .NET Framework 2.0 .
There are 2 webpages:
newrequest.aspx and searchdatabasedialog.aspx
There is a button on the newrequest.aspx webpage that brings up the searchdatabasedialog.aspx webpage in a popup window.
The user can search Locations based on criteria that he or she enters in the search form.
Once the search is complete, the webpage displays the search results on the same page in the same popup
window (the original form's fields get hidden).
The columns displayed and their format (i.e. html or plain text) are as follows:
Location Name Location Alpha Location City Location State Location Office
Html link text text text text
Clicking on the Location Name hyperlink should close the search results webpage and pass the Location Name back to the newrequest.aspx webpage (the Locationname textbox on the newrequest.aspx webpage should get populated.
I have the following JavaScript function defined in the searchdatabasedialog.aspx webpage.
function message(alpha,locname,address1,address2,city,state,zip) {
opener.document.forms[frmNewRequest].elements[txtLocationName].value = locname;
self.close() ;
}
Then, I have the following JavaScript in the Location Name html links in the search results.
<a href=”#” OnClick=”javascript:message(‘’,location_name_returned_from_the_database, ’’,’’,’’,’’,’’) “ ;
I get the following JavaScript error when I click on one of the HTML links returned.
'frmNewRequest is undefined’.
There is a form with id=”frmNewRequest” defined on the newrequest.aspx webpage. I have no clue as to why
it is not finding the 'frmNewRequest' from on the newrequest.aspx . The spelling and casing are correct.
Can anyone spot a problem in the code above? I would appreciate any help.
Thanks.
Saad