Need help!! child and parent window.

Hi,

I have a parent page where I have Selected group list box on it.  The user can filter the data by opening a child page when they are done from their selection and click on the button to add.  the parent group list should get the data from the child page.  

Please, see the image for more detail.

My code so far.
Move the data
function AddtotheList()
{
	$( ".ShowHideAddButton" ).show();
		var SelectedSeg=new Array();
		var SelectedGroup=new Array();
		var dropdownGroup = $("#DispSelectedGroupBox");
		
		$('#DispGroupList option:selected').each(function() {
    			vals = $(this).val()
    			vals=vals.split(",")
           
    			SelectedSeg.push(vals[0])
				SelectedGroup.push(vals[1])
   		})
        SelectedSeg = $.unique( SelectedSeg );
        SelectedGroup = $.unique( SelectedGroup );

		//here how am I going to send the data to the parent page?
		//the dropdown list at the parent page is called "DispSelectedGroupBox"
		//dropdownGroup.html( data );
		//$('#DispSelectedGroupBox').append(value);

                //window.opener.$("#DispSelectedGroupBox").val(SelectedSeg);
                //window.opener.$("#DispSelectedGroupBox").val(SelectedGroup);
}

Open in new window

lulu50Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GaryCommented:
What is that? A textarea, dropdown?
0
lulu50Author Commented:
Hi Cathal!!!!!!1

it is a select

         <select name="DispSelectedGroupBox" id="DispSelectedGroupBox" size="180" multiple="multiple" class="SearchBySelect5"  style="height:100px; width:250px;background-color:#f8fafc;"> </select>

the option should return the data like this 

<option value="#SegmentID#,#GroupNumber#" data-GroupNumber="#GroupNumber#" >#GroupName#</option>

Open in new window

0
GaryCommented:
Are you wanting to append or replace what is already there?
I'm not sure which array you are wanting to pass to it but you should get the idea

window.opener.$("#DispSelectedGroupBox").append("<option>"+SelectedSeg.join("</option><option>")+"</option>");

Open in new window

0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

GaryCommented:
I don't know what #SegmentID#, #GroupNumber# and #GroupNumber relate to...???
0
lulu50Author Commented:
I just want to append



Cathal,

the option should look like this

<option value="#SegmentID#,#GroupNumber#" data-GroupNumber="#GroupNumber#" >#GroupName#</option>

Open in new window


window.opener.$("#DispSelectedGroupBox").append("<option>"+SelectedSeg.join("</option><option>")+"</option>");

Open in new window


so is this correct?

window.opener.$("#DispSelectedGroupBox").append("<option>"+SelectedSeg+SelectedGroup.join("</option><option>"+SelectedName)+"</option>");

Open in new window

0
GaryCommented:
No
What do #SegmentID#, #GroupNumber# and #GroupNumber relate to...???
0
lulu50Author Commented:
Cathal,

this is how the dropdown list on the parent page get populated

<option value="#SegmentID#,#GroupNumber#" data-GroupNumber="#GroupNumber#" >#GroupName#</option>

$('#DispGroupList option:selected').each(function() {
    			vals = $(this).val()
    			vals=vals.split(",")
           
    			SelectedSeg.push(vals[0])
				SelectedGroup.push(vals[1])
				SelectedName.push(vals[2])
   		})
        SelectedSeg = $.unique( SelectedSeg );
        SelectedGroup = $.unique( SelectedGroup );
		SelectedName = $.unique( SelectedName );

#SegmentID# is the SelectedSeg 
#GroupNumber# is the SelectedGroup 
#GroupName# is the SelectedName 

so 

window.opener.$("#DispSelectedGroupBox").append("<option>"+SelectedSeg+SelectedGroup.join("</option><option>"+SelectedName)+"</option>");

I think I need some loop because SegmentID is a list of array the same with GroupNumber and GroupName

Open in new window

0
lulu50Author Commented:
I am doing something wrong but not sure what it is


window.opener.$("#DispSelectedGroupBox").append("<option data-GroupNumber=" + SelectedGroup + " value="+SelectedSeg + "," + SelectedGroup +">"+SelectedName.join("</option><option>")+"</option>");

I am getting this output

<option data-GroupNumber="71472value=4,71472">
Text - URMBT FORD PPO

Open in new window

0
GaryCommented:
Well this is not going to really work since you are making the arrays unique, how to know which SegmentID, GroupNumber and GroupName belong to each other?
0
lulu50Author Commented:
I think in this case I should only have one array instead of three separate one

$('#DispGroupList option:selected').each(function() {
    			vals = $(this).val()
    			vals=vals.split(",")
           
    			SelectedDatapush(vals[0],vals[1],vals[2])

   		})
        SelectedDatapush= $.unique( SelectedDatapush);

Open in new window


something like this?
0
lulu50Author Commented:
this is how it should send the data.

window.opener.$("#DispSelectedGroupBox").append("<option value="+SelectedSeg + "," + SelectedGroup +" data-GroupNumber=" + SelectedGroup + ">"+SelectedName.join("</option><option>")+"</option>");

Open in new window

0
GaryCommented:
Are the arrays (SelectedSeg, SelectedGroup, SelectedName) used for anything else?
It would make more sense to just build the OPTIONS as they are selected in the child.
0
lulu50Author Commented:
I agree! they should get populated directly.

no, they are not used of anything else.

maybe something like this: (It's wrong but I am trying)

hmmm but I do want to remove any duplicate from the list

function AddToTheList()
{
		var SelectedSeg=new Array();
		var SelectedGroup=new Array();
		var SelectedName=new Array();	
		$('#DispGroupList option:selected').each(function() {
    			vals = $(this).val()
    			vals=vals.split(",")
           
		   window.opener.$("#DispSelectedGroupBox").append("<option value="+SelectedSeg.push(vals[0]) + "," + SelectedGroup.push(vals[1]) +" data-GroupNumber=" + SelectedGroup + ">"+SelectedName.push(vals[2]).join("</option><option>")+"</option>");
		
   		})
}

Open in new window

0
GaryCommented:
So you should be using something like this.

function AddtotheList()
{
	$( ".ShowHideAddButton" ).show();
		var SelectedSeg=new Array();
		var SelectedGroup=new Array();
		var dropdownGroup = $("#DispSelectedGroupBox");
		var options="";
		$('#DispGroupList option:selected').each(function() {
    			vals = $(this).val()
    			vals=vals.split(",")
           
			options+='<option value="'+vals[0]+','+vals[1]'" data-GroupNumber="'+vals[2]+'">'+vals[2]+'</option>';

   		})

                window.opener.$("#DispSelectedGroupBox").val(options);
}

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
lulu50Author Commented:
I have syntax error on this line

options+='<option value="'+vals[0]+','+vals[1]'" data-GroupNumber="'+vals[2]+'">'+vals[2]+'</option>';
0
lulu50Author Commented:
fixed it now testing
0
lulu50Author Commented:
hmmm,

I have the values but it's not appending to the parent listbox.

so, it's not appending the data. hmmm
0
lulu50Author Commented:
I changed it to this and it works

   window.opener.$("#DispSelectedGroupBox").append(options);
0
GaryCommented:
Yeah small syntax error.
0
lulu50Author Commented:
Thank you Gary!!!!!!!!!!  for one million and one times lol
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
jQuery

From novice to tech pro — start learning today.