![]() |
| |||||||
| Sponsored Links |
![]() |
| | LinkBack | Thread Tools | Display Modes |
|
#1
| |||
| |||
againAnother one that I've been searching for a while.. how can i change a textbox input language from english to greek? What I mean... In my keyboard I have 2 languages, english and greek. I want, when I type to a textbox, to write in greek, even if the language selected is english. Thank you |
| Sponsored Links |
|
#2
| ||||
| ||||
| The only thing I can think of is to use the JavaScript replace during the onkeyup event and replace the corresponding character with the appropriate Greek character. You could create an array and then read from that array.
__________________ jmurrayhead If you agree with me... click the icon! If my post solved your problem, click the button in the lower right-hand corner of the post.If you like it here...throw us a few bones to help support us. Join our Folding team: DeveloperBarn Folding |
|
#3
| |||
| |||
| Quote:
I mean, while typing the english characters to be replaced by the greek ones.. |
|
#4
| ||||
| ||||
| I think the onKeyUp event will work best for this. See here: JavaScript onkeyup Event You could have an array that holds English characters and Greek characters. Then in the onKeyUp event, find the index of the corresponding English character and use that to find the corresponding Greek character. Then use the JavaScript replace function to replace it: Javascript Tutorial - Replace Hope this helps |
|
#5
| |||
| |||
| I'll try it and I'll let you know.. Thank you.. |
|
#6
| |||
| |||
| Why this doesn't work? ![]() Code: <% function ChkStr(strT) strT = Replace(strT, "a", "α") strT = Replace(strT, "b", "β") ChkStr = strT End Function %> <input type="text" id="test" onKeyUp="ChkStr(this.id)"> |
|
#7
| |||
| |||
| Found it! ![]() Code: function greeklish(x)
{
var y=document.getElementById(x).value;
y=y.replace("a", "α");
y=y.replace("b", "β");
y=y.replace("g", "γ");
document.getElementById(x).value=y
}
<input type="text"
id="greek" onKeyUp="greeklish(this.id)">
|
|
#8
| ||||
| ||||
| I was just about to post this to see if it's any good ![]() Code: function change_letter(id){
var txt = document.getElementById(id).value;
var old_txt = '';
var new_txt = '';
for(var i=txt.length-1;i<txt.length;i++){
old_txt = txt.charCodeAt(i);
//chr ref for a=97 for z=123 isNaN takes care of any other key presses
if(old_txt>=97&&old_txt<=123&&!isNaN(old_txt)){
//difference in chr numbers between a and alpha is 848
new_txt = String.fromCharCode(txt.charCodeAt(i)+848);
//replace the old character for the new one
document.getElementById(id).value = txt.replace(String.fromCharCode(old_txt), new_txt);
}
}
}
To use it:- Code: <input type="text" id="textbox1" onkeyup="change_letter(this.id)" /> I found the difference between the chr values of a and alpha to be 848. So it grabs the last letter from the textbox checks the value is between a and z and then adds 848 to the chr value. Then it replaces the old character with the new one. I thought this would save having to add all the letters manually. The only slight problem with this method is where characters do not have direct replacements. Maybe you could add something in to filter these. Hope that helps. |
|
#9
| |||
| |||
| Quote:
![]() For the english characters that don't exist in greek I did this: Code: if (y.match("c"))
{
alert("Μόνο ελληνικά");
y=y.replace("c", "");
}
The problem though is that with your code starts ok (a=α, b=β, ...) but then it replaces your "m" with our "n", your "k" with our "l" and other... it's not correct.. |
|
#10
| ||||
| ||||
| Yeah...I thought that might be a problem... What you need to do is, if c isn't a letter in greek, any letters after c have to only have 847 added to them. Then if, for example if j isn't a letter in greek, anything after j would only have 846 added to it. Depending on how many letters don't have a replacement, perhaps a switch statement might be better. Hope that makes sense... |
![]() |
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| textbox validation | todd2006 | JavaScript Programming | 6 | July 2nd, 2008 01:30 PM |
| find words and change | todd2006 | JavaScript Programming | 4 | July 2nd, 2008 09:58 AM |
| Change to Reputation System | jmurrayhead | Announcements | 0 | June 2nd, 2008 09:57 PM |
| Textbox or List help | Rebelle | JavaScript Programming | 9 | April 21st, 2008 10:00 AM |