DHTML TabIndex Problem with <SELECT>

Discussion in 'Javascript' started by Delinx32, Jul 16, 2004.

  1. Delinx32

    Delinx32 Guest

    Hi guys,

    I have a pesky problem that I can't seem to shake. I am submitting a
    form to an iframe, and on the iframe's onLoad I am replacing the
    innerHTML of a <DIV> with a new select or input box.

    Basically it works like this:
    1)user changes CITY
    2)user changes STATE
    3)IFRAME runs a cgi exe and fills in the ZIPCODE div with either an
    input box(if one zipcode was returned) or a select box(if several were
    returned)

    When an input box is returned, everything works perfect everytime.
    When a select box returns and I set focus to it, the next tab takes me
    to the address bar instead of the next element.

    The active element stuff is to preserve my tabIndex incase the user
    inadvertantly tabs into the field that is about to change before it
    actually changes, it works properly.

    Don't mind the functions being poorly structured. I thought that the
    problem might have been a javascript order of events thing, but it
    wasn't, and I left the functions the way they were for now.

    There are no duplicate tab indexes.
    I've tried parent.document.recalc();

    Code Below:

    <HTML>
    <SCRIPT>
    var activeElement;
    function getActiveElement()
    {activeElement=parent.document.activeElement.id;}

    function selectItem(anObject)
    {if(anObject.tagName=='INPUT')
    {anObject.focus();anObject.select();}
    else if(anObject.tagName=='SELECT')
    {anObject.focus();}
    };

    function setActiveElement()
    {parent.document.getElementById(activeElement).focus();
    selectItem(parent.document.getElementById(activeElement));
    }

    function doLoad()
    {parent.document.getElementById('ZIPCODE_DIV').innerHTML='<INPUT
    TYPE="TEXT" NAME="ZIPCODE" SIZE="6" VALUE="15317"
    ONCHANGE="document.MAIN.DATAPARENT.value=\'ZIPCODE\';document.MAIN.DATAFIELD.value=\'CITY\';document.MAIN.target=\'COMM\';document.MAIN.action=\'getData\';document.MAIN.submit();"
    TABINDEX="13" TABORDER="13"id="ZIPCODE" class="gtsmallinput">';}

    </SCRIPT>

    <BODY ONLOAD="try{parent.document.MAIN.target='';getActiveElement();doLoad();setActiveElement();}catch(err){alert(err.message)};">

    </BODY>
    </HTML>

    Any help would be greatly appreciated.

    Thanks.
     
    Delinx32, Jul 16, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. samira455
    Replies:
    0
    Views:
    1,072
    samira455
    Sep 12, 2006
  2. mac

    DataGrid problem with tabindex

    mac, Apr 16, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    222
  3. palmiere
    Replies:
    1
    Views:
    450
    Erwin Moller
    Feb 9, 2004
  4. Ilpo
    Replies:
    2
    Views:
    116
  5. Steve
    Replies:
    1
    Views:
    297
    Richard Cornford
    Apr 9, 2005
Loading...

Share This Page