IE selectedIndex problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Johan Daine

    IE selectedIndex problem

    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.ini t.options.selec tedIndex;
    item = document.f2.ini t.options[theindex].value;
    // alert(theindex + ': ' + item);
    if(item=='')
    {
    return;
    }
    cnt = window.opener.d ocument.f1.kwd. value;
    kword = 'window.opener. document.f1.mot _cle_'+ cnt + '.value=\'' + item +
    '\'';
    eval(kword);
    window.opener.d ocument.f1.mot_ cle_1=item;
    cnt = (cnt% 4) +1;
    // alert('cnt= " + cnt);
    window.opener.d ocument.f1.kwd. value = cnt ;
    //alert(window.op ener.document.f 1.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.ini t.options[theindex].value;
    in IE6.0
    Has someone already got this problem... has found some clue?


    Thanks
    Johan Daine

  • @SM

    #2
    Re: IE selectedIndex problem

    Johan Daine a ecrit :
    [color=blue]
    > 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:[/color]

    var item, cnt, kword;
    [color=blue]
    > function addKeyword()[/color]

    this function is declared in page opened in the popup ?
    item, cnt, kword are declared as global variables ? that could help...
    [color=blue]
    > {
    > theindex = document.f2.ini t.options.selec tedIndex;[/color]

    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.select edIndex;
    or
    theindex = document.forms['f2'].elements['init'].options.select edIndex;
    or (après tout, il n'y a qu'1 form et 1 select , non ?)
    item = document.forms[0][0].options.select edIndex;
    what does IE ?
    [color=blue]
    > item = document.f2.ini t.options[theindex].value;[/color]

    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.optio ns[options.selecte dIndex].value; }
    [color=blue]
    >
    > // alert(theindex + ': ' + item);
    > if(item=='')
    > {
    > return;
    > }
    > cnt = window.opener.d ocument.f1.kwd. value;[/color]

    cnt = window.opener.d ocument.forms['f1'].elements['kwd'].value;
    [color=blue]
    >
    > kword = 'window.opener. document.f1.mot _cle_'+ cnt + '.value=\'' + item +
    > '\'';
    > eval(kword);
    > window.opener.d ocument.f1.mot_ cle_1=item;
    > cnt = (cnt% 4) +1;
    > // alert('cnt= " + cnt);
    > window.opener.d ocument.f1.kwd. value = cnt ;
    > //alert(window.op ener.document.f 1.kwd.value);[/color]

    with(window.ope ner.document.fo rms['f1']) {
    kword = elements['mot_cle'+cnt].value = item ; }
    [color=blue]
    > }
    > // 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.ini t.options[theindex].value;
    > in IE6.0
    > Has someone already got this problem... has found some clue?[/color]

    Use the usual maner ?
    <select blabla
    onchange=" R = this.options.se lectedIndex;
    if(R==0) alert('Do an other choice')
    else
    opener.document .forms['f2']['kword'].value=this.opt ions[R].value;
    ">


    --
    *************** *************** *************** *************** **
    Stéphane MORIAUX : mailto:stephane OTER-MOImoriaux@wana doo.fr
    Aide aux Pages Perso (images & couleurs, formulaire, CHP, JS)

    *************** *************** *************** *************** **


    Comment

    • Johan Daine

      #3
      Re: IE selectedIndex problem

      @SM wrote:[color=blue]
      > Johan Daine a ecrit :
      >
      >[color=green]
      >>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:[/color]
      >
      >
      > var item, cnt, kword;
      >
      >[color=green]
      >>function addKeyword()[/color]
      >
      >
      > this function is declared in page opened in the popup ?
      > item, cnt, kword are declared as global variables ? that could help...
      >
      >[color=green]
      >>{
      >>theindex = document.f2.ini t.options.selec tedIndex;[/color]
      >
      >
      > 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.select edIndex;
      > or
      > theindex = document.forms['f2'].elements['init'].options.select edIndex;
      > or (après tout, il n'y a qu'1 form et 1 select , non ?)
      > item = document.forms[0][0].options.select edIndex;
      > what does IE ?
      >
      >[color=green]
      >>item = document.f2.ini t.options[theindex].value;[/color]
      >
      >
      > 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.optio ns[options.selecte dIndex].value; }
      >
      >[color=green]
      >>// alert(theindex + ': ' + item);
      >>if(item=='' )
      >>{
      >> return;
      >>}
      >>cnt = window.opener.d ocument.f1.kwd. value;[/color]
      >
      >
      > cnt = window.opener.d ocument.forms['f1'].elements['kwd'].value;
      >
      >[color=green]
      >>kword = 'window.opener. document.f1.mot _cle_'+ cnt + '.value=\'' + item +
      >>'\'';
      >>eval(kword) ;
      >>window.opener .document.f1.mo t_cle_1=item;
      >>cnt = (cnt% 4) +1;
      >>// alert('cnt= " + cnt);
      >>window.opener .document.f1.kw d.value = cnt ;
      >>//alert(window.op ener.document.f 1.kwd.value);[/color]
      >
      >
      > with(window.ope ner.document.fo rms['f1']) {
      > kword = elements['mot_cle'+cnt].value = item ; }
      >
      >[color=green]
      >>}
      >>// 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.ini t.options[theindex].value;
      >>in IE6.0
      >>Has someone already got this problem... has found some clue?[/color]
      >
      >
      > Use the usual maner ?
      > <select blabla
      > onchange=" R = this.options.se lectedIndex;
      > if(R==0) alert('Do an other choice')
      > else
      > opener.document .forms['f2']['kword'].value=this.opt ions[R].value;
      > ">
      >
      >
      > --
      > *************** *************** *************** *************** **
      > Stéphane MORIAUX : mailto:stephane OTER-MOImoriaux@wana doo.fr
      > Aide aux Pages Perso (images & couleurs, formulaire, CHP, JS)
      > http://perso.wanadoo.fr/stephanePOINTmoriaux/internet/
      > *************** *************** *************** *************** **
      >
      >[/color]
      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

      Comment

      Working...