469,645 Members | 1,150 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,645 developers. It's quick & easy.

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
Jul 23 '05 #1
3 1914
Ivo

"sylvestre" typed
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


Strange indeed. But these precisions leave me clueless. Can we some some
actual code or an url?
Ivo
Jul 23 '05 #2
> Strange indeed. But these precisions leave me clueless. Can we some some
actual code or an url?


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

* the activate/desactivate function:

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

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

* one of the fields definition::

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

Once the "txtPrfBctId" field get activated by stpAct() function, it
causes the form submittion on enter is disabled!
Jul 23 '05 #3
Ivo
"sylvestre" wrote
* the activate/desactivate function:

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

/* assign the step table */
tabObj = tabObjStp[intStp];
/* (des)activate object */
for (intCnt=0;intCnt<tabObj.length;intCnt++)
{
if (tabObj[intCnt][1] == intGrp)
{
objTmp = document.getElementById(tabObj[intCnt][0]);
Add "var " in front of the above line to keep objTmp a local variable.
if (objTmp)
{
if (blnAct)
{
objTmp.disabled = false;
objTmp.className = objTmp.alt;
?
}
else
{
objTmp.disabled = true;
objTmp.value = '';
objTmp.className = 'frmDis';
}
}
}
}
}

* one of the fields definition::

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

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


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
Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Patrick L. Nolan | last post: by
5 posts views Thread by bart plessers | last post: by
1 post views Thread by Ittay Dror | last post: by
7 posts views Thread by George | last post: by
3 posts views Thread by Kelly Domalik | last post: by
1 post views Thread by jediknight | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.