By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,630 Members | 1,313 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,630 IT Pros & Developers. It's quick & easy.

IE selectedIndex problem

P: n/a
Hi everyone,
I have a main page (search engine) that pops up a window in wich the
user can select a keyword in a select box (up to 4 keywords)
The on change attribute of the select tag calls the following function:
function addKeyword()
{
theindex = document.f2.init.options.selectedIndex;
item = document.f2.init.options[theindex].value;
// alert(theindex + ': ' + item);
if(item=='')
{
return;
}
cnt = window.opener.document.f1.kwd.value;
kword = 'window.opener.document.f1.mot_cle_'+ cnt + '.value=\'' + item +
'\'';
eval(kword);
window.opener.document.f1.mot_cle_1=item;
cnt = (cnt% 4) +1;
// alert('cnt= " + cnt);
window.opener.document.f1.kwd.value = cnt ;
//alert(window.opener.document.f1.kwd.value);
}
// kwd is a hidden field in the main page
// f2 is the popup form
// f1 is the main page form
The problem is that although this code works on
Opera 7.2*, Mozilla 1.0.0 (linux)
and Mozilla (?.?) on Win98
I am not able to get a reasonable value for 'item' in the instruction
item = document.f2.init.options[theindex].value;
in IE6.0
Has someone already got this problem... has found some clue?
Thanks
Johan Daine

Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
@SM
Johan Daine a ecrit :
Hi everyone,
I have a main page (search engine) that pops up a window in wich the
user can select a keyword in a select box (up to 4 keywords)
The on change attribute of the select tag calls the following function:
var item, cnt, kword;
function addKeyword()
this function is declared in page opened in the popup ?
item, cnt, kword are declared as global variables ? that could help...
{
theindex = document.f2.init.options.selectedIndex;
1) f2 et f1 sont bien des noms ? et non pas des ids ?
forms are named with 'f1' & 'f2' ? or are they id ?

2) and with :
theindex = document.forms['f2']['init'].options.selectedIndex;
or
theindex = document.forms['f2'].elements['init'].options.selectedIndex;
or (après tout, il n'y a qu'1 form et 1 select , non ?)
item = document.forms[0][0].options.selectedIndex;
what does IE ?
item = document.f2.init.options[theindex].value;
3) et bien sûr :
item = document.forms['f2'].elements['init'].options[theindex].value;

4) si ça ne marche pas employer le code de IE ?
if(document.all) { // to be adapted
item=init.options[options.selectedIndex].value; }

// alert(theindex + ': ' + item);
if(item=='')
{
return;
}
cnt = window.opener.document.f1.kwd.value;
cnt = window.opener.document.forms['f1'].elements['kwd'].value;

kword = 'window.opener.document.f1.mot_cle_'+ cnt + '.value=\'' + item +
'\'';
eval(kword);
window.opener.document.f1.mot_cle_1=item;
cnt = (cnt% 4) +1;
// alert('cnt= " + cnt);
window.opener.document.f1.kwd.value = cnt ;
//alert(window.opener.document.f1.kwd.value);
with(window.opener.document.forms['f1']) {
kword = elements['mot_cle'+cnt].value = item ; }
}
// kwd is a hidden field in the main page
// f2 is the popup form
// f1 is the main page form

I am not able to get a reasonable value for 'item' in the instruction
item = document.f2.init.options[theindex].value;
in IE6.0
Has someone already got this problem... has found some clue?


Use the usual maner ?
<select blabla
onchange=" R = this.options.selectedIndex;
if(R==0) alert('Do an other choice')
else
opener.document.forms['f2']['kword'].value=this.options[R].value;
">
--
************************************************** ************
Stéphane MORIAUX : mailto:st*********************@wanadoo.fr
Aide aux Pages Perso (images & couleurs, formulaire, CHP, JS)
http://perso.wanadoo.fr/stephanePOINTmoriaux/internet/
************************************************** ************
Jul 20 '05 #2

P: n/a
@SM wrote:
Johan Daine a ecrit :

Hi everyone,
I have a main page (search engine) that pops up a window in wich the
user can select a keyword in a select box (up to 4 keywords)
The on change attribute of the select tag calls the following function:

var item, cnt, kword;

function addKeyword()

this function is declared in page opened in the popup ?
item, cnt, kword are declared as global variables ? that could help...

{
theindex = document.f2.init.options.selectedIndex;

1) f2 et f1 sont bien des noms ? et non pas des ids ?
forms are named with 'f1' & 'f2' ? or are they id ?

2) and with :
theindex = document.forms['f2']['init'].options.selectedIndex;
or
theindex = document.forms['f2'].elements['init'].options.selectedIndex;
or (après tout, il n'y a qu'1 form et 1 select , non ?)
item = document.forms[0][0].options.selectedIndex;
what does IE ?

item = document.f2.init.options[theindex].value;

3) et bien sûr :
item = document.forms['f2'].elements['init'].options[theindex].value;

4) si ça ne marche pas employer le code de IE ?
if(document.all) { // to be adapted
item=init.options[options.selectedIndex].value; }

// alert(theindex + ': ' + item);
if(item=='')
{
return;
}
cnt = window.opener.document.f1.kwd.value;

cnt = window.opener.document.forms['f1'].elements['kwd'].value;

kword = 'window.opener.document.f1.mot_cle_'+ cnt + '.value=\'' + item +
'\'';
eval(kword);
window.opener.document.f1.mot_cle_1=item;
cnt = (cnt% 4) +1;
// alert('cnt= " + cnt);
window.opener.document.f1.kwd.value = cnt ;
//alert(window.opener.document.f1.kwd.value);

with(window.opener.document.forms['f1']) {
kword = elements['mot_cle'+cnt].value = item ; }

}
// kwd is a hidden field in the main page
// f2 is the popup form
// f1 is the main page form

I am not able to get a reasonable value for 'item' in the instruction
item = document.f2.init.options[theindex].value;
in IE6.0
Has someone already got this problem... has found some clue?

Use the usual maner ?
<select blabla
onchange=" R = this.options.selectedIndex;
if(R==0) alert('Do an other choice')
else
opener.document.forms['f2']['kword'].value=this.options[R].value;
">
--
************************************************** ************
Stéphane MORIAUX : mailto:st*********************@wanadoo.fr
Aide aux Pages Perso (images & couleurs, formulaire, CHP, JS)
http://perso.wanadoo.fr/stephanePOINTmoriaux/internet/
************************************************** ************

Thanks for your advices, I am accessing access the forms or elements
with the forms or elements hashes.
It now works withe IE6 and linux browsers including Konqueror ;)

Johan Daine

Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.