On a form, I want to jump to the next tabindex when pressing the 'enter' key. The script that should do the thing, should look like this (the tabindex is generated dynamically and the code is simplified):
<form id='MyForm'>
<?php
$tabindex = 1;
?>
<input class='pts' type='text' id='<?php echo $row['id']; ?>' tabindex='<?php echo $tabindex; ?>' onkeypress='convertEnterKey(this);' />
<?php
$tabindex++;
?>
</form>
<script type="text/javascript">
function convertEnterKey(obj) {
var k;
if(window.event.which) {
k = window.event.which.keyCode;
} else {
// needed for IE
k = window.event.keyCode;
}
if (k == 13){
nextTabIndex = obj.tabIndex + 1;
for(i=0;i<document.MyForm.elements.length;i++){
if(document.MyForm.elements(i).tabIndex==nextTabIndex){
document.MyForm.elements(i).focus();
break;
}
}
}
}
</script>
On the net I found there is some difference between FF and IE, but I can not find the exact explanation and/or implementation.
Could someone please help me out?
Thanks in advance!!!
Sincerely,
Steve