473,503 Members | 722 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Updating The Drop-Down List On One Window From Another

Hi All,

I'm trying to alter the contents of a drop-down (select) list on the
parent window from a child window in IE 6. After opening the child
window, I set its opener to reference the parent like this:

childwin = window.open(...)
if (childwin == null)
childwin.opener = self;

Then, to update the parent select list from the child window, I do
this:

opener.document.myForm.NameOfSelect.options.length = 0;
opener.document.myForm.NameOfSelect.options[0] = new Option("", "");
for (var ixy = 1; ixy <= newDataArray.length; ixy++)
{
opener.document.myForm.NameOfSelect.options[ixy] = new
Option(someNewDisplayText, newValue);
}
This looks correct and works up to a point. I can empty the parent
select by setting the its options.length to zero. But, when I try to
add new options, IE gives me a "server threw an exception" message.
Is all this even possible in IE?

TIA.
Jul 23 '05 #1
2 2281
Hi Robert
The following works in IE5 with no doctype. I hope it helps
Jimbo

html file to with list and button to open new window
<HTML><HEAD><TITLE>populate select opener</TITLE>
<script type=text/javascript>
var listOptions=new Array("Sat","Sun","Mon","Tues","Wed","Thurs","Fri" );
function changeList(index) {
// use index to decide how to populate list
// this example uses the listOptions array
var a=document.forms["whatever"].elements["openerList"];
for (var i=0;i<listOptions.length;i++)
a[i]=new Option(listOptions[i]);
}
function openNewWin() {
winRef=window.open("popselectwin2.htm");
}
</script></HEAD>
<BODY>
<form name="whatever">
<select name="openerList"><option>day1<option>day2</select>
<button onclick="openNewWin()">Open Window</button></form>
</BODY></HTML>
html for window that gets opened
<HTML><HEAD> <TITLE>populate select in opener</TITLE></HEAD>
<BODY>
<select
onchange=window.opener.changeList(this.selectedInd ex)><option>one<option>two
</select>
</BODY></HTML>
I hope this helps
"Robert Nurse" <rn****@cudbytech.net> wrote in message
news:a9*************************@posting.google.co m...
Hi All,

I'm trying to alter the contents of a drop-down (select) list on the
parent window from a child window in IE 6. After opening the child
window, I set its opener to reference the parent like this:

childwin = window.open(...)
if (childwin == null)
childwin.opener = self;
The above code is suspicious. if(childwin==null) the window wasn't opened
and your reference to childwin.opener and further assignment should at least
throw a fit if not an exception.

Then, to update the parent select list from the child window, I do
this:

opener.document.myForm.NameOfSelect.options.length = 0;
opener.document.myForm.NameOfSelect.options[0] = new Option("", "");
for (var ixy = 1; ixy <= newDataArray.length; ixy++)
{
opener.document.myForm.NameOfSelect.options[ixy] = new
Option(someNewDisplayText, newValue);
}
looks OK. maybe window.opener is safer
This looks correct and works up to a point. I can empty the parent
select by setting the its options.length to zero. But, when I try to
add new options, IE gives me a "server threw an exception" message.
Is all this even possible in IE?

TIA.

Jul 23 '05 #2
Hi Jimbo,

You're exactly right! I had to set up a function on the parent window
for the child to call so that it could update the list on the parent.
Phew, that was a mouthful. Anyway, thanks for you suggestion.

"J. J. Cale" <ph****@netvision.net.il> wrote in message news:<41********@news.012.net.il>...
Hi Robert
The following works in IE5 with no doctype. I hope it helps
Jimbo

html file to with list and button to open new window
<HTML><HEAD><TITLE>populate select opener</TITLE>
<script type=text/javascript>
var listOptions=new Array("Sat","Sun","Mon","Tues","Wed","Thurs","Fri" );
function changeList(index) {
// use index to decide how to populate list
// this example uses the listOptions array
var a=document.forms["whatever"].elements["openerList"];
for (var i=0;i<listOptions.length;i++)
a[i]=new Option(listOptions[i]);
}
function openNewWin() {
winRef=window.open("popselectwin2.htm");
}
</script></HEAD>
<BODY>
<form name="whatever">
<select name="openerList"><option>day1<option>day2</select>
<button onclick="openNewWin()">Open Window</button></form>
</BODY></HTML>
html for window that gets opened
<HTML><HEAD> <TITLE>populate select in opener</TITLE></HEAD>
<BODY>
<select
onchange=window.opener.changeList(this.selectedInd ex)><option>one<option>two
</select>
</BODY></HTML>
I hope this helps
"Robert Nurse" <rn****@cudbytech.net> wrote in message
news:a9*************************@posting.google.co m...
Hi All,

I'm trying to alter the contents of a drop-down (select) list on the
parent window from a child window in IE 6. After opening the child
window, I set its opener to reference the parent like this:

childwin = window.open(...)
if (childwin == null)
childwin.opener = self;


The above code is suspicious. if(childwin==null) the window wasn't opened
and your reference to childwin.opener and further assignment should at least
throw a fit if not an exception.

Then, to update the parent select list from the child window, I do
this:

opener.document.myForm.NameOfSelect.options.length = 0;
opener.document.myForm.NameOfSelect.options[0] = new Option("", "");
for (var ixy = 1; ixy <= newDataArray.length; ixy++)
{
opener.document.myForm.NameOfSelect.options[ixy] = new
Option(someNewDisplayText, newValue);
}

looks OK. maybe window.opener is safer

This looks correct and works up to a point. I can empty the parent
select by setting the its options.length to zero. But, when I try to
add new options, IE gives me a "server threw an exception" message.
Is all this even possible in IE?

TIA.

Jul 23 '05 #3

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

Similar topics

11
16070
by: Jason | last post by:
Let's say I have an html form with 20 or 30 fields in it. The form submits the fields via POST to a php page which updates a table in a database with the $_POST vars. Which makes more sense? ...
7
2479
by: Paige | last post by:
I have a database on my local machine that I make entries and corrections on. I'd like to be able to upload that to my server and have that update the database that's on the server. What I've been...
4
2680
by: Sky Fly | last post by:
Hello all, I've written a stored procedure which runs OK for the first few thousand records it processes, then around about the 10,000th record it suffers a sudden and dramatic drop in...
8
11577
by: pb648174 | last post by:
I have a single update statement that updates the same column multiple times in the same update statement. Basically i have a column that looks like .1.2.3.4. which are id references that need to...
5
4455
by: deko | last post by:
How to run action query against linked table? I have an Access 2003 mdb with an Excel 2003 Workbook as a linked table. When I attempt to run an action query against the linked table I get this...
1
1712
by: teddyparnell | last post by:
I have a query that works, but then displays the results in a datasheet view. The query is reliant on the results of a combo box, and when i update this combo box and click a button the results of...
8
1370
by: Zest4Csharp | last post by:
hi, I have a database table without a key field. I managed to view the contents of the table through a DataSet in a DataGrid in C#. The user can edit the data in the grid. Can someone show me how...
4
2593
by: Dave Taylor | last post by:
I've been using the dataset designer in Visual Studio to create typed datasets for my application by dragging over tables from the Server Explorer and dropping them into the designer. The problem...
3
4623
by: John Morgan | last post by:
I have my first small SQl Server 2005 database developed on my local server and I have also its equivalent as an online database. I wish to update the local database (using and asp.net interface)...
2
2760
by: breimer | last post by:
I have created a simple database with a single date field & inserted the current date. What I need to do is alter the day portion of this date field to be a value of 01 if the day of the current...
0
7089
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7339
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...
1
6995
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...
0
7463
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...
0
5581
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3168
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...
0
3157
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1515
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
389
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...

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.