jquery - tabbing between jeditable fields in a table -
i'm using code here http://www.korvus.com/blog/geek/making-the-tab-key-work-with-jeditable-fields/ tabbing between jeditable fields working, , if fields on own works fine. need have fields in table, , time tab key works tabbing last field first, , of course need tab first next , on...
$('div.edit').bind('keydown', function(evt) { if(evt.keycode==9) { $(this).find("input").blur(); var nextbox=''; if ($("div.edit").index(this) == ($("div.edit").length-1)) { nextbox=$("div.edit:first"); //last box, go first } else { nextbox=$(this).next("div.edit"); //next box in line } $(nextbox).click(); //go assigned next box return false; //suppress normal tab }; });
the table formatted this
<table> <tr> <td class='leftcolumn'> <strong>firstname:</strong> </td> <td> <div class='edit' id='firstname'><?=$userdetail['firstname']?></div> </td> </tr> <tr> <td class='leftcolumn'> <strong>lastname:</strong> </td> <td> <div class='edit' id='lastname'><?=$userdetail['lastname']?></div> </td> </tr> </table>
thanks in advance
i believe issue input fields not direct siblings each other, "next()" failing. think work:
$('div.edit').bind('keydown', function(evt) { if(evt.keycode==9) { var nextbox=''; var currentboxindex=$("div.edit").index(this); if (currentboxindex == ($("div.edit").length-1)) { nextbox=$("div.edit:first"); //last box, go first } else { nextbox=$("div.edit").eq(currentboxindex+1); //next box in line } $(this).find("input").blur(); $(nextbox).click(); //go assigned next box return false; //suppress normal tab }; });
Comments
Post a Comment