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

Need to pass back selected value text/option to previous page

Status
Not open for further replies.

PushCode

Programmer
Dec 17, 2003
573
US
I have a popup lookup page which lets the user search for a company name, then a dropdown is populated with the results. The user then clicks on one of the results and the previous page's (window.opener) text field is populate with the value from the selected item, and the popup window automatically closes. Works well so far, but I'm only able to pass back the value, whereas I need to also pass back the text/option of that selection. I thought changing the
=document.getElementById('" + ddlSupplier.ClientID + "').value to =document.getElementById('" + ddlSupplier.ClientID + "').selectedIndex would do the trick but it doesn't work. Nothing gets passed back. I'm guessing is trickier than that b/c this is sharepoint.

Here's the relevant c# code:
Code:
string theTxtVal;
            theTxtVal = Request.QueryString["cid"];
            string theHidVal;
            theHidVal = Request.QueryString["hid"];
            ddlSupplier.Attributes.Add("onChange", "window.opener.document.getElementById('" + theTxtVal + "').value=document.getElementById('" + ddlSupplier.ClientID + "').selectedIndex;window.close();");
 
Got it working...here's what I did:

string theTxtVal;
theTxtVal = Request.QueryString["cid"];
string theHidVal;
theHidVal = Request.QueryString["hid"];
ddlSupplier.Attributes.Add("onChange", "window.opener.document.getElementById('" + theHidVal + "').value=document.getElementById('" + ddlSupplier.ClientID + "').value;window.opener.document.getElementById('" + theTxtVal + "').value=document.getElementById('" + ddlSupplier.ClientID + "').options[document.getElementById('" + ddlSupplier.ClientID + "').options.selectedIndex].text;window.close();");
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top