is it possible to autotab through radio buttons

Results 1 to 2 of 2

Thread: is it possible to autotab through radio buttons

  1. #1
    Join Date
    Dec 1969

    Default is it possible to autotab through radio buttons

    &nbsp;<BR>I have some forms with groups of radio buttons, <BR>ex. 50 questions on a page with a group of radio buttons 1-5<BR>each, i want to be able to just type 2 4 1 3, and after each number pressed it will tab to next rb group, is there a way to get the index of the element its in and set focus to next element(++) on keyup ??<BR>any suggestions ..<BR><BR>Thank u

  2. #2
    Join Date
    Dec 1969

    Default This may help...

    I use the following javascript functions to auto tab on some of my forms(all my fields are text type, however I believe it should work for radio buttons too):<BR><BR>Here are the functions:<BR><BR>&#060;SCRIPT LANGUAGE="JavaScript"&#062;<BR>&#060;!--<BR><BR>var isNN = (navigator.appName.indexOf("Netscape")!=-1);<BR>function autoTab(input,len, e) {<BR>var keyCode = (isNN) ? e.which : e.keyCode; <BR>var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];<BR>if(input.value.length &#062;= len && !containsElement(filter,keyCode)) {<BR>input.value = input.value.slice(0, len);<BR>input.form[(getIndex(input)+1) % input.form.length].focus();<BR>input.form[(getIndex(input)+1) % input.form.length].select();<BR>}<BR><BR>function containsElement(arr, ele) {<BR>var found = false, index = 0;<BR>while(!found && index &#060; arr.length)<BR>if(arr[index] == ele)<BR>found = true;<BR>else<BR>index++;<BR>return found;<BR>}<BR><BR>function getIndex(input) {<BR>var index = -1, i = 0, found = false;<BR>while (i &#060; input.form.length && index == -1)<BR>if (input.form[i] == input)index = i;<BR>else i++;<BR>return index;<BR>}<BR>return true;<BR>}<BR><BR>// --&#062;<BR>&#060;/SCRIPT&#062;<BR><BR>To use simply call the function in the onKeyUp event for each form element:<BR><BR>&#060;input type="text" name="field1" onKeyUp="return autoTab(this, 1, event);"&#062;<BR><BR>Hope that helps<BR><BR>Pete

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts