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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trouble with passing text between 2 webpages using JavaScript

Status
Not open for further replies.

techsaad

Programmer
Dec 31, 2008
6
US
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
 
You need to put the form and element names in quotes:
Code:
function message(alpha,locname,address1,address2,city,state,zip) {
        opener.document.forms[[b][red]'[/red][/b]frmNewRequest[b][red]'[/red][/b]].elements[[b][red]'[/red][/b]txtLocationName[b][red]'[/red][/b]].value = locname;
        self.close() ;
}

Lee
 

I ended up doing:

opener.document.forms[0].elements['TabContainer$TbPanel5$txtLocationName'].value = locname;

The Textbox in on a tab panel in a TabContainer control.


Thanks for your help.

Saad
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top