napsternapster Posted May 11, 2009 Share Posted May 11, 2009 Is there a way in javascript to set the focus on the item with the next tabIndex value? and generate dynamic tabindex using javascript I thank you in advince. Quote Link to comment https://forums.phpfreaks.com/topic/157672-tabindexing-using-javascript/ Share on other sites More sharing options...
Ken2k7 Posted May 11, 2009 Share Posted May 11, 2009 Yes there is. You basically just set a condition on the input fields to tell when to have the function focus() to set off and what field you want to put focus on. Not hard. Quote Link to comment https://forums.phpfreaks.com/topic/157672-tabindexing-using-javascript/#findComment-831570 Share on other sites More sharing options...
napsternapster Posted May 12, 2009 Author Share Posted May 12, 2009 The syntax is not as easy as you are saying and I've tried your advance but z giving producing an endless loop.Think of aform which has thousands of text boxes and select dropdowns your roles is to display the next textbox after a select drop down selection and set the focus on the new display. basic syntax for reading the textboxes using javascript for(var i = 1; i <= out_count;i++) { for(var b = 1 ; b <=middle_count ;b++) { for(var g = 1; g <=9;g++) { var textBox = document.getElementById("txt"+i"_"+b+"_"g).id var selection = document.getElementById("sel"+i"_"+b+"_"g)).id if(document.getElementById(selection).id == 'inline) { next_index++ document.getElementById(info_id).tabIndex = next_index; document.getElementById(info_id).tabIndex = document.getElementById(info_id).focus(); } else if(document.getElementById(selselection id).style.display == 'inline') { next_index++; document.getElementById(selection ).tabIndex = next_index; document.getElementById(selection ).tabIndex = document.getElementById(selection ).focus(); } } } } } Quote Link to comment https://forums.phpfreaks.com/topic/157672-tabindexing-using-javascript/#findComment-832214 Share on other sites More sharing options...
Ken2k7 Posted May 12, 2009 Share Posted May 12, 2009 Talk about a mess. O_O You're over-did this by a mile! You need to add an onKeyUp attribute to each input box. Then just write that one function, with maybe one or two helper functions. Quote Link to comment https://forums.phpfreaks.com/topic/157672-tabindexing-using-javascript/#findComment-832402 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.