473,414 Members | 1,692 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

text direction right to left for arabic text input

Dear Sir,
Is there any way or property for chaning the text diriction from right to left automatically when i want to take arabic text as a input . now this possible by ALT+SHIFT pressing . but i want to do it automatically by using javscript or style sheet .
Please try to reply to me.

Regards,
Faruk Chowdhury
May 22 '08 #1
21 16830
hsriat
1,654 Expert 1GB
Dear Sir,
Is there any way or property for chaning the text diriction from right to left automatically when i want to take arabic text as a input . now this possible by ALT+SHIFT pressing . but i want to do it automatically by using javscript or style sheet .
Please try to reply to me.

Regards,
Faruk Chowdhury
See the text direction property if its of any use.

If not then you may have a look at dir and lang attribute of textarea tag.

Place a language selector radio button and call the function to change the properties onclick event of the radio button.

PS. Ask such questions in JavaScript forum.
May 22 '08 #2
Atli
5,058 Expert 4TB
I have moved this thread over to the Javascript Forums.
Please try to post you questions in the appropriate forums.

Thanks.
May 22 '08 #3
Dear Sir,
When I press Alt+Shift in a text control, the cursor turns Right-To-Left.
I want it without pressing Alt+Shift, I want to when I click a text control
the cursor automatically turn to Right-To-Left.
please try to reply.

Thanks in advance.

Regards,
Faruk Chowdhury
May 22 '08 #4
Dear Sir,
Thank you for your quick reply.
When I press Alt+Shift in a text control, the cursor turns Right-To-Left.
I want it without pressing Alt+Shift, I want to when I click a text control
the cursor automatically turn to Right-To-Left.

i sent this question to javascript forum also.

According to your previous reply the direction goes from left to right but i need as when I click a text control the cursor automatically turn to Right-To-Left.

so if you can please help me.

thanks in advance.

Regards,
Faruk Chowdhury


See the text direction property if its of any use.

If not then you may have a look at dir and lang attribute of textarea tag.

Place a language selector radio button and call the function to change the properties onclick event of the radio button.

PS. Ask such questions in JavaScript forum.
May 22 '08 #5
hsriat
1,654 Expert 1GB
According to your previous reply the direction goes from left to right but i need as when I click a text control the cursor automatically turn to Right-To-Left.

so if you can please help me.

thanks in advance.

Regards,
Faruk Chowdhury
Expand|Select|Wrap|Line Numbers
  1. function urduWriter(onOrOff) {
  2.     document.getElementById('ta').style.direction =onOrOff ? 'rtl' : 'ltr';
  3.     //document.getElementById('ta').dir = onOrOff ? 'rtl' : 'ltr'; 
  4. }
Call this function to change the direction from right to left as urduWriter(true).
To restore the direction, call urduWriter(false)
May 22 '08 #6
acoder
16,027 Expert Mod 8TB
Merged threads. Thread had already been moved to this forum.

Moderator.
May 23 '08 #7
Plater
7,872 Expert 4TB
I am really unsure why this link did not solve the problem:
http://www.w3schools.com/htmldom/pro..._direction.asp
May 23 '08 #8
hsriat
1,654 Expert 1GB
I am really unsure why this link did not solve the problem:
http://www.w3schools.com/htmldom/pro..._direction.asp
I guess he's not aware of how to change this property with JavaScript.
Or perhaps the w3school's server was down when he clicked this link.

But its working, I just tested...
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">function urduWriter(onOrOff) {
  2.     document.getElementById('ta').style.direction =onOrOff ? 'rtl' : 'ltr';
  3. }
  4. </script>
  5. <textarea id="ta"></textarea><br>
  6. <button onclick="urduWriter(true);">On</button>
  7. <button onclick="urduWriter(false);">Off</button>
May 23 '08 #9
Plater
7,872 Expert 4TB
I guess he's not aware of how to change this property with JavaScript.
Or perhaps the w3school's server was down when he clicked this link.
Why not just build your html pages with it set already? The OP said js/CSS but it might have been because they were unaware that it can be done with a regular html attribute.
May 23 '08 #10
hsriat
1,654 Expert 1GB
Why not just build your html pages with it set already? The OP said js/CSS but it might have been because they were unaware that it can be done with a regular html attribute.
good point...
but I have seen such pages.. they show radio button by which you can select the language you want to type in... I just guessed it might be similar caase...

so this will work ...[html]<textarea dir="rtl"></textarea>[/html]
May 23 '08 #11
Plater
7,872 Expert 4TB
There are a number things I have discovered here. Text direction seems to automatically inherit from it's parent object:
Expand|Select|Wrap|Line Numbers
  1. <html>
  2.     <head>
  3.         <title>Direction Test</title>
  4.         <script type="text/javascript">
  5.             function changeTextDirection()
  6.             {
  7.                 var curdir=document.getElementById("mybody").style.direction;
  8.                 if(curdir=="ltr")
  9.                 {
  10.                     document.getElementById("mybody").style.direction="rtl";
  11.                 }
  12.                 else
  13.                 {
  14.                     document.getElementById("mybody").style.direction="ltr";
  15.                 }
  16.             }
  17.         </script>
  18.  
  19.     </head>
  20.     <body id="mybody" dir="rtl">
  21.         <span >fred jones</span><br/>
  22.         <div > bibbidy bop</div><br/>
  23.         <input type="text" value="some text" /><br/>
  24.         <textarea >This is some text</textarea><br/>
  25.         <input type="button" dir="inherit" onclick="changeTextDirection();" value="Swap It"/>
  26.     </body>
  27. </html>
  28.  
There is also a css property:
Expand|Select|Wrap|Line Numbers
  1. p { 
  2.   direction:ltr; 
  3.  
http://www.1keydata.com/css-tutorial/text.php#direction


So if you only want the inputboxes/textareas to switch, you can apply a special CSS tag to them and have them all start out with the right-to-left set.
May 23 '08 #12
Dear Sir,
Thank you for cooperation.
my problem is with the use of ALT+SHIFT in the input box to write arabic text. i want to do this automatically i.e when i click in the input box the ALT+ SHIFT task will be done by programatically .
According to your code the directiong is changing from left to right but still i have to use the ALT+SHIFT key for taking the arabic input.

So if you have any idea please write to me.

Thanks in advance .

Regards,
Faruk Chowdhury



There are a number things I have discovered here. Text direction seems to automatically inherit from it's parent object:
Expand|Select|Wrap|Line Numbers
  1. <html>
  2.     <head>
  3.         <title>Direction Test</title>
  4.         <script type="text/javascript">
  5.             function changeTextDirection()
  6.             {
  7.                 var curdir=document.getElementById("mybody").style.direction;
  8.                 if(curdir=="ltr")
  9.                 {
  10.                     document.getElementById("mybody").style.direction="rtl";
  11.                 }
  12.                 else
  13.                 {
  14.                     document.getElementById("mybody").style.direction="ltr";
  15.                 }
  16.             }
  17.         </script>
  18.  
  19.     </head>
  20.     <body id="mybody" dir="rtl">
  21.         <span >fred jones</span><br/>
  22.         <div > bibbidy bop</div><br/>
  23.         <input type="text" value="some text" /><br/>
  24.         <textarea >This is some text</textarea><br/>
  25.         <input type="button" dir="inherit" onclick="changeTextDirection();" value="Swap It"/>
  26.     </body>
  27. </html>
  28.  
There is also a css property:
Expand|Select|Wrap|Line Numbers
  1. p { 
  2.   direction:ltr; 
  3.  
http://www.1keydata.com/css-tutorial/text.php#direction


So if you only want the inputboxes/textareas to switch, you can apply a special CSS tag to them and have them all start out with the right-to-left set.
May 23 '08 #13
Plater
7,872 Expert 4TB
Ok, well alt+shift does nothing for me, so it must be some special language support feature on your system.
It does not have anything to do with the text direction it would seem so that was a red herring.

I am not sure how you would change the system local of a client machine through a webpage, maybe somebody else can help?
May 23 '08 #14
hsriat
1,654 Expert 1GB
Dear Sir,
Thank you for cooperation.
my problem is with the use of ALT+SHIFT in the input box to write arabic text. i want to do this automatically i.e when i click in the input box the ALT+ SHIFT task will be done by programatically .
According to your code the directiong is changing from left to right but still i have to use the ALT+SHIFT key for taking the arabic input.

So if you have any idea please write to me.

Thanks in advance .

Regards,
Faruk Chowdhury
Did you try the post # 9?
May 23 '08 #15
Tarantulus
114 100+
I think everybody is missing the point here, the gent is trying to get his CURSOR to move "in reverse" so he can type input the arabic way...

unfortunately, I think this is impossible...

the alt+shift thing is a windows language setup, and thus cannot be controlled from a browser window.

EDIT: ActiveX perhaps, but thats IE specific, and VERY dodgy....
May 23 '08 #16
Plater
7,872 Expert 4TB
Reverse? When text goes right to left, so does the cursor right?
In RTL mode if i press c u r s e r I see in my textbox ressuc| where the | is my cursor. Everything is lined up to the right hand side. Opposite of left to right writing.
May 23 '08 #17
hsriat
1,654 Expert 1GB
Reverse? When text goes right to left, so does the cursor right?
In RTL mode if i press c u r s e r I see in my textbox ressuc| where the | is my cursor. Everything is lined up to the right hand side. Opposite of left to right writing.
No, actually the Arabic languages are written from right to left like this
...E...D...C...B...A
<-- <-- <--

(of course they don't call it ABCD..)

So what he (OP) exactly wants is.
1. Text should be right aligned
2. When a letter is typed, the cursor should come in the left of the recently typed letter, instead of right side of the letter.

Just assume it like you are looking at the monitor through a mirror while typing English in the textarea.

The solutions dir and style.direction just fulfills the first need listed above, but not the second one.

So for the second one, you would need to find the position of the cursor (caret position). And using focus(caret), move the cursor to caretPosition-1 position every time you type in something (onkeypress). This won't be very easy though.

PS: Google for "Urdu editor JavaScript", you may find something useful.
May 23 '08 #18
Dear Sir,
Thanks to all.
can you tell me how to execute key sequenec combinition using javascript i.e when i will click a buttton it will execute the key code for ALT and SHIFT key ?
please try to write to me.

Regards,
Faruk Chowdhury

No, actually the Arabic languages are written from right to left like this
...E...D...C...B...A
<-- <-- <--

(of course they don't call it ABCD..)

So what he (OP) exactly wants is.
1. Text should be right aligned
2. When a letter is typed, the cursor should come in the left of the recently typed letter, instead of right side of the letter.

Just assume it like you are looking at the monitor through a mirror while typing English in the textarea.

The solutions dir and style.direction just fulfills the first need listed above, but not the second one.

So for the second one, you would need to find the position of the cursor (caret position). And using focus(caret), move the cursor to caretPosition-1 position every time you type in something (onkeypress). This won't be very easy though.

PS: Google for "Urdu editor JavaScript", you may find something useful.
May 25 '08 #19
hsriat
1,654 Expert 1GB
Dear Sir,
Thanks to all.
can you tell me how to execute key sequenec combinition using javascript i.e when i will click a buttton it will execute the key code for ALT and SHIFT key ?
please try to write to me.

Regards,
Faruk Chowdhury
Believe me, that's not going to work. ALT SHIFT is just a language setting on your machine but not general.

And you are not even telling what is the problem with the solutions we provided. How long can we keep on doing guess work?
May 25 '08 #20
Dear Sir,
According the previous solutions it just changes the direction from left to right .
i think for my prblem i need to know how to execute key code sequence by javascript.
please if you can try to reply to me.

Thanks in advance .

Regards,
Faruk Chowdhury.
May 26 '08 #21
acoder
16,027 Expert Mod 8TB
You could try manually firing events, though I don't know if it would work. Have a read.
May 27 '08 #22

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: suhaddad | last post by:
I have an XML schema that I want to modify. I need to change the text from English to Arabic, but I can't seem to be able to do so. <LearningResourceData Type="Session - Tutorial and Workouts">...
1
by: Khan | last post by:
Hi all, I have a textbox 'remarks' in jsp which has some arabic text. while pressing the submit button the arabic text is storing in java string variable. String rem = ...
1
by: jrs_14618 | last post by:
Hello All, This post is essentially a reply a previous post/thread here on this mailing.database.myodbc group titled: MySQL 4.0, FULL-TEXT Indexing and Search Arabic Data, Unicode I was...
1
by: Santosh | last post by:
dear all i want to change text direction of text box with in datagrid control i am writting following code but it is not working. public void SetUpClientScript(object sender,...
3
by: Sjef Janssen | last post by:
Is it possible to have a box (div) which sets a background-color and which contains (on the same line) text which is left aligned and text which is right aligned. (as in a table: two td's left one...
0
by: pflynn | last post by:
I need to center the text in a div within its natural width (ie the width of the longest line) and then place that div on the RH side of the window. <div id="#ident"> <div id="#address"> ...
2
by: RobinS | last post by:
Is it possible to left-justify, center, or right-justify text on a panel when drawing it using DrawString? I looked at the StringAlignment class, but all it has is far, near, and center. ...
1
by: hash4sp | last post by:
Hello ! DBF file consists of a field i.e."districts" which holds data in Arabic language. DBF file is in ANSI format. How to convert this ANSI format so that it displays actual Arabic text on the...
2
by: sebouh181 | last post by:
Hello everyone I have an ASP.NET website with arabic interface. When I type arabic text and at the end of the text I put a point, the point is displayed at the beginning of the text. ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.