Jeg prøver at sætte et autoTab script op men har et problem... Når jeg tilføjer mit autoTab script så "udelukker" den de andre scripts?
Her er hvad jeg har:
- function stroke_calc()
- {
- var i,s=[];
- for (i=0; i<=17; i++)
- {
- s[i]=validNum(document.form2["stroke"+i].value);
- }
- var s_out = s[0] + s[1] + s[2] + s[3] + s[4] + s[5] + s[6] + s[7] + s[8];
- var s_in = s[9] + s[10] + s[11] + s[12] + s[13]+ s[14] + s[15] + s[16] + s[17];
-
- document.form2.stroke_out.value = s_out;
- document.form2.stroke_in.value = s_in;
- document.form2.stroke_total.value = s_out + s_in;
- }
-
- var isNN = (navigator.appName.indexOf("Netscape")!=-1);
- function autoTab(input, e) {
- var keyCode = (isNN) ? e.which : e.keyCode;
- var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
- if (input.value == 1) {
- if(input.value.length >= 2 && !containsElement(filter,keyCode)) {
- input.value = input.value.slice(0, 2);
- input.form[(getIndex(input)+1) % input.form.length].focus();
- input.form[(getIndex(input)+1) % input.form.length].select();
- }
- } else {
- if(input.value.length >= 1 && !containsElement(filter,keyCode)) {
- input.value = input.value.slice(0, 2);
- input.form[(getIndex(input)+1) % input.form.length].focus();
- input.form[(getIndex(input)+1) % input.form.length].select();
- }
- }
-
- function containsElement(arr, ele) {
- var found = false, index = 0;
- while(!found && index < arr.length)
- if(arr[index] == ele)
- found = true;
- else
- index++;
- return found;
- }
- function getIndex(input) {
- var index = -1, i = 0, found = false;
- while (i < input.form.length && index == -1)
- if (input.form[i] == input)index = i;
- else i++;
- return index;
- }
- return true;
- }
Og her er min form:
- echo '<form name="form2">';
-
- for ($i = 0; $i <= 8; $i++) {
- echo '<input name="stroke'.$i.'" onKeyup="return autoTab(this, 1, event);stroke_calc();" class="style1" value="'.${'stroke'.$i}.'" maxlength="2"><br>';
- }
- echo '<input name="stroke_out" readonly=true class="style2" value="0" onfocus="this.form.stroke9.focus();"><br>';
- for ($i = 9; $i <= 17; $i++) {
- echo '<input name="stroke'.$i.'" onKeyup="return autoTab(this, 1, event);stroke_calc();'.$matchCalc.'gir_calc();" class="style1" value="'.${'stroke'.$i}.'" maxlength="2"><br>';
- }
-
- echo '</form>';
Håber virkelig at nogen kan hjælpe, for jeg forstår det simpelthen ikke