Connecting Tech Pros Worldwide Forums | Help | Site Map

Setting options on a select box (ComboBox) - in another window

jodleren
Guest
 
Posts: n/a
#1: Mar 30 '07
Hi!

I use this to read on the value of my "parent" window.

stemp=window.opener.document.forms[0].workgroup.value;

Works well.

Say, I'd like to add an items to that, and select it?

stemp=window.opener.document.forms[0].workgroup.options[0].value="hello
world";
- does not work.

Any ideas?


Marc
Guest
 
Posts: n/a
#2: Mar 30 '07

re: Setting options on a select box (ComboBox) - in another window


"jodleren" <sonnich@hot.eewrote in message
news:1175266139.719735.261120@d57g2000hsg.googlegr oups.com...
Quote:
Hi!
>
I use this to read on the value of my "parent" window.
>
stemp=window.opener.document.forms[0].workgroup.value;
>
Works well.
>
Say, I'd like to add an items to that, and select it?
>
stemp=window.opener.document.forms[0].workgroup.options[0].value="hello
world";
- does not work.
>
Any ideas?
>
How about:

addOptions(window.opener.document.forms[0].workgroup, 0, "hello");
/* oValue can also be a string */
function addOptions(object, oValue, oText) {
var defaultSelected = true; var selected = true;
var optionName = new Option(oText, oValue, defaultSelected, selected)
var length = object.length;
object.options[length] = optionName;
}


jodleren
Guest
 
Posts: n/a
#3: Mar 31 '07

re: Setting options on a select box (ComboBox) - in another window


On Mar 30, 9:40 pm, "Marc" <sorry...@dirtymail.comwrote:
Quote:
"jodleren" <sonn...@hot.eewrote in message
>
news:1175266139.719735.261120@d57g2000hsg.googlegr oups.com...
>
>
>
>
>
Quote:
Hi!
>
Quote:
I use this to read on the value of my "parent" window.
>
Quote:
stemp=window.opener.document.forms[0].workgroup.value;
>
Quote:
Works well.
>
Quote:
Say, I'd like to add an items to that, and select it?
>
Quote:
stemp=window.opener.document.forms[0].workgroup.options[0].value="hello
world";
- does not work.
>
Quote:
Any ideas?
>
How about:
>
addOptions(window.opener.document.forms[0].workgroup, 0, "hello");
/* oValue can also be a string */
function addOptions(object, oValue, oText) {
var defaultSelected = true; var selected = true;
var optionName = new Option(oText, oValue, defaultSelected, selected)
var length = object.length;
object.options[length] = optionName;
Quote:
}
I tried something like that, but never got it to work.

I might take a look at that later, but I had another problem here -
that when reloading the page (location.reload og history.go(0)) it
asked whether to repost data.

Therefore I came up this:
a hidden value on the form, which can be set from the popup window.
Then I submit it. Like this:

window.opener.document.forms[0].reload.value="yes";
window.opener.document.forms[0].submit();

Then I check the $_post[reload] when submitted :-)

I think of it as a nice solution. It will the reload the combobox, and
avoid the forms main submit functionality.

BR
Sonnich

Closed Thread