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

Insert value from pop-up 1

Status
Not open for further replies.
May 9, 2000
446
GB
Hi, i have a form that users have to select a member of staff from. There are loads of members of staff so i have a button that the user clicks and a popup appears.
First of all they select which client the staff member works for and then they are shown a different page displaying a list of members of staff for that client

Anyway i need to have a button in the seond page of the pop-up that inserts the staff members uniqueID into a txtbox on the original form in the window that opened the first popup. Have i explained that okay?
anyway any help would be great

Cheers
 
OK, I understand that your visitor first selects a Client then goes to page #2 where all of the staff members for that client are listed. Then, I think, you want a button to open a new window.

Then I lost you.. Exactly what do you want to show up in the new window and what do you want to be done with the parent window, if anything.

ToddWW
 
Sorry not to good at explaining! Okay here goes...
1.User clicks on a 'Select Staff Member' button on first main page.

2.Pop-up appears listing all clients, user selects a client and clicks button.

3.Pop-up loads staff members page using client code to determine which members of staff are shown.

4. The user selects a member of staff from a drop down menu

The above works fine but... what i don't know how to do is...

5.User thens clicks a button that writes the staff member code to a text box on the original main page that opened the pop-up in the first place.

I have a similar pop-up that lists clients straight away and uses 'opener' to write the client code to but i can't get it to work after the pop-up has gone to a second page as the pop-up not the main page is now the opener!

Think thats better...
Cheers
Gary

 
Easy: Use frame names...

Example of this is create a page with ONE frame that takes up the whole browser window, name it &quot;MainWindowPage&quot; Load a page that has a form inside it with a textbox named &quot;text1&quot; When this page loads, fill the value of text1 with <% = Request(&quot;text1&quot;) %> Also have a button or another link that loads your pop-up...

From your pop-up window add a client-side javascript that re-loads the first page when you click submit.
Code:
function DoRefresh(FillVal) {
  window.open ('NameOfPage.asp?text1=' + FillVal, 'MainWindowPage');
  window.close ();
}
Of course, you will want to modify this. And a consideration is depending on browser settings, It make not let you run window.close();


Kevin
 
When a user selects the person they want, store it as a session variable then on your main page.
1. set asp to write out a javascript function to reload your page when focus is gained (if the session variable does not exsist).
2. set asp to create the textbox if the session variable does exsist

I have not tried this however I think that the result should be that when your pop up window goes away and your main page regains focus the main page should now find the session variable with the persons name, then print the text box and not print the reload javascript.
 
OK, now I'm with you. Assuming that actions #4 and #5 take place in the pop up window and the the staff member code is located in the value paramater of the staff list like this.
Code:
<select name=&quot;stafflist&quot;>
  <option value=&quot;membercode1&quot;>Member Name #1</option>
  <option value=&quot;membercode2&quot;>Member Name #2</option>
  <option value=&quot;membercode3&quot;>Member Name #3</option>
</select>
Then you will have a button in the popup window like this.
Code:
<input type=&quot;button&quot; value=&quot;Place Member Code Into Parent Page&quot; onClick=&quot;moveCode(this.form);&quot;>

Now this example assumes that both the select list of staff members and the button that moves the member code to the parent page are in the same form. I say this because I'm using the this.form parameter in the function call to pass form reference to the moveCode() function.

Right a JavaScript function in the popup window like this.

<head>
<script Language=&quot;JavaScript&quot;>
<!--
function moveCode(form_ref) {
self.opener.
formname.textfieldname.value = form_ref.stafflist.options[form_ref.stafflist.selectedIndex].value
}
//-->
</script>
</head>


When you press the button in the popup window, it will take the value of the currently selected option in the staff list and place it into the text field in the parent window.

Let me know if you need any additional help.

ToddWW :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top