(I apologize for the vague title.)
Hello, I’ve got this code that I don’t see any problems with but it only works in certain conditions.
[code=php]
var digit=new Array();
digit[0]=”u3007″;
digit[1]=”u4E00″;
digit[2]=”u4E8C”;
digit[3]=”u4E09″;
digit[4]=”u56DB”;
digit[5]=”u4E94″;
digit[6]=”u516D”;
digit[7]=”u4E03″;
digit[8]=”u516B”;
digit[9]=”u4E5D”;
digit[10]=”u5341″;
digit[100]=”u767E”;
function number_conv(form) {
if (form.roomaji.value >= 0) {
if (form.roomaji.value.charAt(form.roomaji.value.length – 1)==”.”) {
form.textarea.value+=digit[eval(form.roomaji.value)];
form.roomaji.value=””;
}
}
}
EDIT-for some reason, the forum is splitting up the word ‘length’ above; thats not reason the code isn’t working ๐ฎ
form.roomaji is just a textbox that numbers will be entered into. When a number is entered, it will check to see if there is a period at the end (like 1.), if so, it will enter the corresponding value (without the period) from the digit array. It works for all one digit numbers (0-9), however it won’t work with 10 or 100 (anything with more than two digits.) Can anyone see a problem?
This is the form that corresponds with this function:
[code=php]
<form name=’form’>
<input name=”roomaji” type=”text” onkeyup=”number_conv(this.form)” size=”25″>
<br>
<textarea name=”textarea” cols=”66″ rows=”25″></textarea>
</form>
Thank you in advance for any help.
-Steve