Problem with JS disabled fields

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

    Problem with JS disabled fields

    Hi,

    I've a little script that disables/enables some fields in a form. It
    works correctly, no problem.
    Problem arise when a disabled field becomes enabled again: the enter
    key pressed in that field do not trigger the form submittion, or any
    other "onXXX" event. But it does not raise a JS error either... Of
    course, if the same field is enabled when page loads, the enter key
    works perfectely well and submits the form. So it's really the state
    change that cause the problem. To make it even more strange, once the
    enter key has been pressed without effect, the enter key submittion is
    disabled in all other fields, even the ones which status have not been
    changed!!

    Precisions:
    - problem shows under IE 5.5 or 6.0.
    - there are no specific treatment on key press, only events are
    onBlur and onFocus

    Could someone help me on this ?

    Sylvestre
  • Ivo

    #2
    Re: Problem with JS disabled fields


    "sylvestre" typed[color=blue]
    > I've a little script that disables/enables some fields in a form. It
    > works correctly, no problem.
    > Problem arise when a disabled field becomes enabled again: the enter
    > key pressed in that field do not trigger the form submittion, or any
    > other "onXXX" event. But it does not raise a JS error either... Of
    > course, if the same field is enabled when page loads, the enter key
    > works perfectely well and submits the form. So it's really the state
    > change that cause the problem. To make it even more strange, once the
    > enter key has been pressed without effect, the enter key submittion is
    > disabled in all other fields, even the ones which status have not been
    > changed!!
    >
    > Precisions:
    > - problem shows under IE 5.5 or 6.0.
    > - there are no specific treatment on key press, only events are
    > onBlur and onFocus[/color]

    Strange indeed. But these precisions leave me clueless. Can we some some
    actual code or an url?
    Ivo


    Comment

    • sylvestre

      #3
      Re: Problem with JS disabled fields

      > Strange indeed. But these precisions leave me clueless. Can we some some[color=blue]
      > actual code or an url?[/color]

      No url, it's internal application, but here is some code:

      * the activate/desactivate function:

      function stpAct(intStp,i ntGrp,blnAct)
      {
      var intCnt;
      var tabObj;

      /* assign the step table */
      tabObj = tabObjStp[intStp];
      /* (des)activate object */
      for (intCnt=0;intCn t<tabObj.length ;intCnt++)
      {
      if (tabObj[intCnt][1] == intGrp)
      {
      objTmp = document.getEle mentById(tabObj[intCnt][0]);
      if (objTmp)
      {
      if (blnAct)
      {
      objTmp.disabled = false;
      objTmp.classNam e = objTmp.alt;
      }
      else
      {
      objTmp.disabled = true;
      objTmp.value = '';
      objTmp.classNam e = 'frmDis';
      }
      }
      }
      }
      }

      * one of the fields definition::

      <input tabindex="3" onBlur="stpVal( 3)" onFocus="stpSel Fld(3)"
      name="txtPrfBct Id" type="text" size="3" maxlength="2" value=""
      class="frmDis" alt="frmOpt" disabled>

      Once the "txtPrfBctI d" field get activated by stpAct() function, it
      causes the form submittion on enter is disabled!

      Comment

      • Ivo

        #4
        Re: Problem with JS disabled fields

        "sylvestre" wrote[color=blue]
        > * the activate/desactivate function:
        >
        > function stpAct(intStp,i ntGrp,blnAct)
        > {
        > var intCnt;
        > var tabObj;
        >
        > /* assign the step table */
        > tabObj = tabObjStp[intStp];
        > /* (des)activate object */
        > for (intCnt=0;intCn t<tabObj.length ;intCnt++)
        > {
        > if (tabObj[intCnt][1] == intGrp)
        > {
        > objTmp = document.getEle mentById(tabObj[intCnt][0]);[/color]

        Add "var " in front of the above line to keep objTmp a local variable.
        [color=blue]
        > if (objTmp)
        > {
        > if (blnAct)
        > {
        > objTmp.disabled = false;
        > objTmp.classNam e = objTmp.alt;[/color]

        ?
        [color=blue]
        > }
        > else
        > {
        > objTmp.disabled = true;
        > objTmp.value = '';
        > objTmp.classNam e = 'frmDis';
        > }
        > }
        > }
        > }
        > }
        >
        > * one of the fields definition::
        >
        > <input tabindex="3" onBlur="stpVal( 3)" onFocus="stpSel Fld(3)"
        > name="txtPrfBct Id" type="text" size="3" maxlength="2" value=""
        > class="frmDis" alt="frmOpt" disabled>
        >
        > Once the "txtPrfBctI d" field get activated by stpAct() function, it
        > causes the form submittion on enter is disabled![/color]

        I can't immediately point out the erronous semicolon. Just make general
        suggestion to add some debug alerts at various spots to trace the flow of
        running code (also in function stpVal as hitting enter may or may not invoke
        the onblur event), use alt attributes in images, not in input elements. What
        global variable is tabObjStp? Looks like a deep heavy nasty multinested
        array, are you sure it contains expected values? How stpAct() is called,
        with what arguments, is also of interest of course.
        Perhaps put up a public testpage.
        Ivo


        Comment

        Working...