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

x
?
Solved

Need help!! child and parent window.

Posted on 2014-03-06
20
Medium Priority
?
326 Views
Last Modified: 2014-03-07
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

0
Comment
Question by:lulu50
[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
  • 12
  • 8
20 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 39910274
What is that? A textarea, dropdown?
0
 

Author Comment

by:lulu50
ID: 39910284
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
 
LVL 58

Expert Comment

by:Gary
ID: 39910295
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 58

Expert Comment

by:Gary
ID: 39910310
I don't know what #SegmentID#, #GroupNumber# and #GroupNumber relate to...???
0
 

Author Comment

by:lulu50
ID: 39910330
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
 
LVL 58

Expert Comment

by:Gary
ID: 39910334
No
What do #SegmentID#, #GroupNumber# and #GroupNumber relate to...???
0
 

Author Comment

by:lulu50
ID: 39910389
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
 

Author Comment

by:lulu50
ID: 39910434
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
 
LVL 58

Expert Comment

by:Gary
ID: 39910435
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
 

Author Comment

by:lulu50
ID: 39910446
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
 

Author Comment

by:lulu50
ID: 39910481
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
 
LVL 58

Expert Comment

by:Gary
ID: 39910497
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
 

Author Comment

by:lulu50
ID: 39912460
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
 
LVL 58

Accepted Solution

by:
Gary earned 2000 total points
ID: 39912557
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
 

Author Comment

by:lulu50
ID: 39912570
I have syntax error on this line

options+='<option value="'+vals[0]+','+vals[1]'" data-GroupNumber="'+vals[2]+'">'+vals[2]+'</option>';
0
 

Author Comment

by:lulu50
ID: 39912593
fixed it now testing
0
 

Author Comment

by:lulu50
ID: 39912609
hmmm,

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

so, it's not appending the data. hmmm
0
 

Author Comment

by:lulu50
ID: 39912611
I changed it to this and it works

   window.opener.$("#DispSelectedGroupBox").append(options);
0
 
LVL 58

Expert Comment

by:Gary
ID: 39912615
Yeah small syntax error.
0
 

Author Closing Comment

by:lulu50
ID: 39912785
Thank you Gary!!!!!!!!!!  for one million and one times lol
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

609 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