Problem with JS disabled fields

S

sylvestre

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
 
I

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
 
S

sylvestre

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!
 
I

Ivo

* 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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,144
Latest member
KetoBaseReviews
Top