text direction right to left for arabic text input

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • farukcse
    New Member
    • Nov 2007
    • 52

    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
  • hsriat
    Recognized Expert Top Contributor
    • Jan 2008
    • 1653

    #2
    Originally posted by farukcse
    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.

    Comment

    • Atli
      Recognized Expert Expert
      • Nov 2006
      • 5062

      #3
      I have moved this thread over to the Javascript Forums.
      Please try to post you questions in the appropriate forums.

      Thanks.

      Comment

      • farukcse
        New Member
        • Nov 2007
        • 52

        #4
        text direction right to left

        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

        Comment

        • farukcse
          New Member
          • Nov 2007
          • 52

          #5
          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


          Originally posted by hsriat
          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.

          Comment

          • hsriat
            Recognized Expert Top Contributor
            • Jan 2008
            • 1653

            #6
            Originally posted by farukcse
            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
            Code:
            function urduWriter(onOrOff) {
                document.getElementById('ta').style.direction =onOrOff ? 'rtl' : 'ltr';
                //document.getElementById('ta').dir = onOrOff ? 'rtl' : 'ltr'; 
            }
            Call this function to change the direction from right to left as urduWriter(true ).
            To restore the direction, call urduWriter(fals e)

            Comment

            • acoder
              Recognized Expert MVP
              • Nov 2006
              • 16032

              #7
              Merged threads. Thread had already been moved to this forum.

              Moderator.

              Comment

              • Plater
                Recognized Expert Expert
                • Apr 2007
                • 7872

                #8
                I am really unsure why this link did not solve the problem:
                Last edited by Plater; May 23 '08, 02:41 PM. Reason: sss

                Comment

                • hsriat
                  Recognized Expert Top Contributor
                  • Jan 2008
                  • 1653

                  #9
                  Originally posted by Plater
                  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...[code=javascript]
                  <script type="text/javascript">fun ction urduWriter(onOr Off) {
                  document.getEle mentById('ta'). style.direction =onOrOff ? 'rtl' : 'ltr';
                  }
                  </script>
                  <textarea id="ta"></textarea><br>
                  <button onclick="urduWr iter(true);">On </button>
                  <button onclick="urduWr iter(false);">O ff</button>[/code]

                  Comment

                  • Plater
                    Recognized Expert Expert
                    • Apr 2007
                    • 7872

                    #10
                    Originally posted by hsriat
                    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.

                    Comment

                    • hsriat
                      Recognized Expert Top Contributor
                      • Jan 2008
                      • 1653

                      #11
                      Originally posted by Plater
                      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]

                      Comment

                      • Plater
                        Recognized Expert Expert
                        • Apr 2007
                        • 7872

                        #12
                        There are a number things I have discovered here. Text direction seems to automatically inherit from it's parent object:
                        [code=html]
                        <html>
                        <head>
                        <title>Directio n Test</title>
                        <script type="text/javascript">
                        function changeTextDirec tion()
                        {
                        var curdir=document .getElementById ("mybody").styl e.direction;
                        if(curdir=="ltr ")
                        {
                        document.getEle mentById("mybod y").style.direc tion="rtl";
                        }
                        else
                        {
                        document.getEle mentById("mybod y").style.direc tion="ltr";
                        }
                        }
                        </script>

                        </head>
                        <body id="mybody" dir="rtl">
                        <span >fred jones</span><br/>
                        <div > bibbidy bop</div><br/>
                        <input type="text" value="some text" /><br/>
                        <textarea >This is some text</textarea><br/>
                        <input type="button" dir="inherit" onclick="change TextDirection() ;" value="Swap It"/>
                        </body>
                        </html>
                        [/code]

                        There is also a css property:
                        [code=css]
                        p {
                        direction:ltr;
                        }
                        [/code]

                        Explores the different ways CSS can be used to manage the display of text. Visit 1Keydata to learn CSS now.



                        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.

                        Comment

                        • farukcse
                          New Member
                          • Nov 2007
                          • 52

                          #13
                          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



                          Originally posted by Plater
                          There are a number things I have discovered here. Text direction seems to automatically inherit from it's parent object:
                          [code=html]
                          <html>
                          <head>
                          <title>Directio n Test</title>
                          <script type="text/javascript">
                          function changeTextDirec tion()
                          {
                          var curdir=document .getElementById ("mybody").styl e.direction;
                          if(curdir=="ltr ")
                          {
                          document.getEle mentById("mybod y").style.direc tion="rtl";
                          }
                          else
                          {
                          document.getEle mentById("mybod y").style.direc tion="ltr";
                          }
                          }
                          </script>

                          </head>
                          <body id="mybody" dir="rtl">
                          <span >fred jones</span><br/>
                          <div > bibbidy bop</div><br/>
                          <input type="text" value="some text" /><br/>
                          <textarea >This is some text</textarea><br/>
                          <input type="button" dir="inherit" onclick="change TextDirection() ;" value="Swap It"/>
                          </body>
                          </html>
                          [/code]

                          There is also a css property:
                          [code=css]
                          p {
                          direction:ltr;
                          }
                          [/code]

                          Explores the different ways CSS can be used to manage the display of text. Visit 1Keydata to learn CSS now.



                          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.

                          Comment

                          • Plater
                            Recognized Expert Expert
                            • Apr 2007
                            • 7872

                            #14
                            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?

                            Comment

                            • hsriat
                              Recognized Expert Top Contributor
                              • Jan 2008
                              • 1653

                              #15
                              Originally posted by farukcse
                              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?

                              Comment

                              Working...