Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Data from child window to parent window

Posted on 2001-06-27
1
Medium Priority
?
524 Views
Last Modified: 2008-03-03
Hey,

I'm trying to pass the contents of a selection box from a pop-up window to a selection box in it's parent window, but I can't figure it out.

I know that this works:

Child window:

function sendToParent(){
window.opener.document.form.parent.value=document.form.child.value;
}

...

<input type="text" name="child" size=45>
<input type="button" name="cmdsend" value="Send" onclick="sendToParent()">

...

Parent window:

...

<input type="text" Name="parent" size=45>

...

SO what this does it whatever you type into the text field in child window and hit 'send', then that value will show up in the text field parent in the parent window.

What I was thinking was to use this logic with a selection box. In my child window, I add a new field into the database and update the table. The selection box displays all the current fields of that table. So I want to be able to send this newly updated info back to the parent window's selection box.

Is this possible? (Please say yes!)

I'm trying to do it this way instead of reloading the parent page, because if I reload the parent page, information that the user might have entered in input fields will disappear on the refresh, because that info isn't saved yet.

If there's another way to do this (Ie sending the updated information back to the parent window) I'm open for suggestions..

Cheers
0
Comment
Question by:scuzzy20
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 14

Accepted Solution

by:
puranik_p earned 200 total points
ID: 6233883
yes!!
it's very much possible.
some kind of code you can do with is given below
what u have to do is call these functions from appropriate buttons (don't forget you can keep buttons hidden and then call their "onclick" from child window
like..
window.opener.yourbutton.onclick()
)

here it goes...

<script language = "JavaScript" >
     function PopulatePeriod(Period)
     {    
          RemoveFromList()
          PopWith(Period)
     }
     
     function RemoveFromList()
     {
          var i;
          for(i=0;i<document.PeriodForm.START.length;i++)
          {
               {
                    document.PeriodForm.START.options[i] = null;
                    document.PeriodForm.END.options[i] = null;
                    i--
               }
          }
     }
     
     function PopWith(Period)
     {

          if (Period == "Weeks")
          {
               var ArrPeriod = new Array
               ArrPeriod[0] = "Select Week"
               for(i=1;i<=52;i++)
               {
                    ArrPeriod[i] = "Week" + i
               }
          }
          if (Period == "Months")
          {
               var ArrPeriod = new Array
               ArrPeriod[0] = "Select Month"
               ArrPeriod[1] = "JAN"
               ArrPeriod[2] = "FEB"
               ArrPeriod[3] = "MAR"
               ArrPeriod[4] = "APR"
               ArrPeriod[5] = "APR"
               ArrPeriod[6] = "JUN"
               ArrPeriod[7] = "JUL"
               ArrPeriod[8] = "AUG"
               ArrPeriod[9] = "SEP"
               ArrPeriod[10] = "OCT"
               ArrPeriod[11] = "NOV"
               ArrPeriod[12] = "DEC"
          }
          if (Period == "Quarters")
          {
               var ArrPeriod = new Array
               ArrPeriod[0] = "Select Quarter"
               for(i=1;i<=4;i++)
               {
                    ArrPeriod[i] = "Quarter" + i
               }
          }
          if (Period == "Years")
          {
               var ArrPeriod = new Array
               ArrPeriod[0] = "Select Year"
               for(i=1;i<=11;i++)
               {
                    ArrPeriod[i] = 1999 + i
               }
          }

          for(i=0;i<=ArrPeriod.length - 1;i++)
          {
               var optionValue = ArrPeriod[i]
               var newOptionName = new Option(optionValue);
               document.PeriodForm.START.options[document.PeriodForm.START.length] = newOptionName;
               var optionValue1 = ArrPeriod[i]
               var newOptionName1 = new Option(optionValue1);              
               document.PeriodForm.END.options[document.PeriodForm.END.length] = newOptionName1;
          }
     }
     
     function Go()
     {
          alert("FetchingRecords")
          document.PeriodForm.action = "PeriodSearch.asp?Mode=Submitted"
          document.PeriodForm.submit()
     }

</script>
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…

596 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question