473,581 Members | 2,338 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Appending option items in dropdown in parent window from dropdown in Child window in IE

I am trying to append options to dropdown in parent window from option
items in child window.

In parent window, I have following code:

<script language="javas cript">
function AddItem2DropDow n(item){
exists = false;
for(d=0;d<drpDw n.length;d++){
if(drpDwn.optio ns[d].value == item.value)
exists = true;
}
if(exists == false)
drpDwn.options[drpDwn.length] = item;
}
</script>

Then in child window, I have following code:

<script language="javas cript">
function AddItems(child) {
for(i=0;i<child .length;i++){
if(child.option s[i].selected == true)
window.opener.A ddItem2DropDown (child.options[i]);
}
}
</script>

It works in Firefox, but not in IE6. Has anyone got this working in
IE6?

Jul 23 '05 #1
2 3800
Bostonasian wrote:
I am trying to append options to dropdown in parent window from option
items in child window.

In parent window, I have following code:

<script language="javas cript">
function AddItem2DropDow n(item){
exists = false;
for(d=0;d<drpDw n.length;d++){
if(drpDwn.optio ns[d].value == item.value)
exists = true;
}
if(exists == false)
drpDwn.options[drpDwn.length] = item;
}
</script>

Then in child window, I have following code:

<script language="javas cript">
function AddItems(child) {
for(i=0;i<child .length;i++){
if(child.option s[i].selected == true)
window.opener.A ddItem2DropDown (child.options[i]);
}
}
</script>

It works in Firefox, but not in IE6. Has anyone got this working in
IE6?


Not criticising, but I'm impressed that this works in any browser.
You've succeeded in 'cutting' an Option object from one window's list
box and 'pasting' it into a list box in an entirely different window.
You don't tell us which error you get in IE (at best, I get "the server
threw an exception"), but in any case I'd recommend a different approach.

Firstly, in your parent window, if you make your 'add' function a method
of the window, its existence can be easily tested for. Then, have it
create a completely fresh Option object based upon the parameter(s)
passed to it:

window.add2Drop Down = function(str, val)
{
var selBox = document.forms[0].elements["drpDwn"];
var opt = new Option;

opt.text = str;
opt.value = val;

selBox.options[selBox.length] = opt;
}

(I haven't duplicated your 'test if already exists' code).

In your child window, test for the existence: first, of the parent
window and then of the 'add' function. If successful, pass it the value
(or values) that indicate the Option you want to create:

....
if(window.opene r && window.opener.a dd2DropDown)
{
window.opener.a dd2DropDown(chi ld.options[i].text, child.options[i].value);
// then remove the item from the child's list box:
child.options[i] = null;
}...
Jul 23 '05 #2
Great! Thanks, your code works.

Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
1715
by: JP SIngh | last post by:
I have three dropdowns in one of my asp page. Each dropdown does return a huge amount of records , 5000 to be precise. The huge amount of data makes the page slower to load and also makes it extermly diffcult for users to choose one value from the list. Does someone have a better solution to implement this? I guess one of the things...
1
2132
by: Sakharam Phapale | last post by:
Hi All, How to show dropdown list of menu items just like click on Parent menu. For example, Edit (Parent menu) Cut (child menu) Copy (child menu) Paste (child menu)
1
2240
by: Jason Huang | last post by:
Hi, I want to create a Web form in asp.net, using C#. So in a web page, we have one DropDown List or one DataGrid, that when we click an item from a dropdown list, there will pop up another web page which have details regarding to the dropdown list item. This is similar to the Parent/Child in the visual basic 6. But I have no idea how to...
1
11556
by: Earl Teigrob | last post by:
I did a ton of searching to try and find a simple solution to this issue and finally wrote my own, which I am sharing with everyone. In my searching, I did find a very complete and robust solution at http://weblogs.asp.net/asmith/archive/2003/09/15/27684.aspx but it was far more complex then I needed. (I got lost trying to figure it all...
0
1584
by: fwirtanen | last post by:
I am building a custom composite control consisting of two drop downs, with parent/child dependancy. The child dropdownlist is updated through client callback when the parent index changes. An 'All' list item is added to the child dropdown during the CreateControlHeirarchy(bool useDataSource) method. Somewhere between the...
2
2338
by: Sakharam Phapale | last post by:
Hi All, How to show dropdown list of menu items just like click on Parent menu. For example, Edit (Parent menu) Cut (child menu) Copy (child menu) Paste (child menu)
13
2844
by: PetterL | last post by:
I writing a program where I read menu items from a file. But I have problem when I click an menu item i want it to mark that one as checked but I cant access the menu object of that item to see witch object was selected. This is the sub procedure that read the items from an Array and create the menutitem. The array hold more information to...
1
3456
by: bytesFTW99 | last post by:
I have been struggling with this for some time can anyone help out? just trying to have 3 dropdown boxes that fill depending on what is selected, then in some cases click a button and have the second set of 3 dropdown boxes be filled with the same values. thank you <head> <SCRIPT LANGUAGE="JavaScript" type="text/javascript"> var...
0
8144
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8301
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7894
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8169
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5670
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3803
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3820
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1400
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1132
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.