Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tabindex does not work after onBlur function with Netscape

Status
Not open for further replies.

celia05es

Programmer
Jan 10, 2002
81
US
Hello,

I am having problems using NETSCAPE with the tabindexes after using the "onBlur" Javascript function. I have been looking and looking and I can't find what is wrong!!!.

Basically, I have the following:
- field1
- field2
- field3
- field4
...etc
Field 2 and field3 are inicially disabled.
What I want to do is:
- If I enter something in field1 => I want field2 and field3 to be automatically enabled.. and obviously I want the cursor to be on field2. Sounds easy right?

Now:
CASE 1: Field 1 is empty:
- I use the "tabulator" from field1.... and the cursor goes to field4: CORRECT.

CASE 2: Field1 is not empty:
- I use the "tabulator".... field3 and field4 are enabled .... but the cursor goes to field4!!!!!

It works perfectly with Explorer but not with Netscape 7.0

Could you help ?


Here is part of my coding:
....
Function initForm1(form)
{
var f1=form.field1.value;
if (!f1.match(/^(\s)*$/) )
{
form.field2.disabled=false;
form.field3.disabled=false;
form.field2.focus();
}
else
{
form.field2.disabled=true;
form.field2.value="";
form.field3.disabled=true;
form.field3.value="";
}
}

.....
Field1:
<input type=text name="field1" tabindex=3 onBlur="initForm1(this.form);"
<br>
Field2:
<input type=text name="field2" tabindex=4>
<br>
Field3:
<input type=text name="field3" tabindex=5>
<br>
Field4:
<input type=text name="field4" tabindex=6>
.....
 

While I cannot say for sure, it is possible that when a field is disabled, NN7 removes or alters the tabIndex (it would certainly explain what you're seeing).

How about programatically setting the tabindex values back to what you want after enabling the fields? In IE this should make no difference, but it might fix the NN7 behaviour.

Hope this helps,
Dan
 
I am sorry but I don't understand what you mean.
I think that with Netscape, when the onblur event is triggered.. the function is called before the onblur occurs... so everything gets mixed up.
Certainly what you are saying makes sense ... but could you explain it to me, please?
 
Hello,

I have been given a solution (see script below) that has partially solved the problem: It only considers the first text box. I need a general function but I don't have a clue how to write it . I know that the basic problem is that NS requires the focus to occur after the function completetion (for this reason the timeout call has been used)


With the following script if I use the tabulator from field2 it does not go to field3. Once the fields have been enabled, I need to use the tab to go from field1, to field2, to field3 and to field4.

Someone could help me ?


Many Thanks

===============================

<script>
function initForm1(form)
{form.field2.focus()
var f1=form.field1.value;
if (!/^(\s)*$/.test(f1) )
{
form.field2.disabled=false;
form.field3.disabled=false;
elem=form.field2
setTimeout('elem.focus()',10);

}
else
{
form.field2.disabled=true;
form.field2.value="";
form.field3.disabled=true;
form.field3.value="";
}
}

function disableFields()
{
document.form1.field2.disabled=true;
document.form1.field3.disabled=true;
}

</script>
<body onLoad=disableFields()>

<form id="form1">
<p>Field1:
<input type="text" name="field1" tabindex="3" onblur="initForm1(this.form);">
<br>Field2:
<input type="text" name="field2" tabindex="4">
<br>Field3: <input type="text" name="field3" tabindex="5">
<br>Field4: <input type="text" name="field4" tabindex="6">
</p>
</form>
 
Problem solved.... using onKeyUp instead of onBlur!

Thanks to everyone.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top