(@[EMAIL PROTECTED] resetting taborders in HTML...aaaarrrrggghhhhhh! )

hi all

I have to toggle some form fields on and off (readonly and unable to
focus to). Because the whole form is built dynamically I can't (ie:
too painful) use the previous form field to work out what the next
"tab-able" field is, so...

I'm (trying) to do this by setting the particular tabindex to a
negative number and when it gets reset, change them back to a positive
tabIndex.

(test code below)

the trouble is that it won't reset properly - the tabIndex values are
OK but the reset tab order is not back to where it started -
especially when the initlal tabIndex's start higher than 1 (ie "11"
which is what it will be in the form)

has anyone got dynamic tab ordering working using javascript?
can this be done?
if so, any suggestions on what might be wrong?
if not is there a better way? 

thanx
barry.b


===========================================
<html>
<head>
<script>
        function changeTabOrder(theForm){
                var fieldlist = 'text2,text3,text5';
                var fieldarray = fieldlist.split(",");
                var temp = '';
                var origTabIndex = 1;
                for(var i=0; i < fieldarray.length; i++){
                        temp = fieldarray[i];
                        alert("before change " + theForm[temp].name + ": " +
theForm[temp].tabIndex);
                        origTabIndex = theForm[temp].tabIndex;
                        theForm[temp].tabIndex = origTabIndex * -1;
                        alert("after change " + theForm[temp].name + ": " + 
theForm[temp].tabIndex);
                        }
        }
        
        function resetTabIndex(theForm){
                var theElems = theForm.elements;
                 // loop over the elements until finding a non-hidden one
                for (i = 0; i < theElems.length; i++) {
                        var theElem = theElems[i];
                        alert("before reset " + theElem.name + ": " + 
theElem.tabIndex);        
                        var oldIndex = parseInt(theElem.tabIndex);
                        theElem.tabIndex = Math.abs(parseInt(oldIndex));
                        alert("after reset " + theElem.name + ": " + 
theElem.tabIndex); 
                }       
        }
        
        function showDebug(formElement){
                //alert("tabIndex for " + formElement.name + ": " + 
formElement.tabIndex);
        }       
</script>
</head>
<body onload="document.getElementById('text1').focus()">
<form name="frm" id="frm">
<input type="text" name="text1" id="text1" tabindex="11"
onfocus="showDebug(this)"><br>
<input type="text" name="text2" id="text2" tabindex="12"
onfocus="showDebug(this)">(test case)<br>
<input type="text" name="text3" id="text3" tabindex="13"
onfocus="showDebug(this)">(test case)<br>
<input type="text" name="text4" id="text4" tabindex="14"
onfocus="showDebug(this)"><br>
<input type="text" name="text5" id="text5" tabindex="15"
onfocus="showDebug(this)">(test case)<br>
<input type="text" name="text6" id="text6" tabindex="16"
onfocus="showDebug(this)"><br>
<input type="Button" name="change" id="change" value="Change Tab
Order" onClick="changeTabOrder(this.form)" tabindex="1"><br>
<input type="Button" name="reset" id="reset" value="Reset Tab Order"
onclick="resetTabIndex(this.form)" tabindex="2"><br>
</form>
</body>
</html>
============================================

---
You are currently subscribed to cfaussie as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]
Aussie Macromedia Developers: http://lists.daemon.com.au/

Reply via email to