473,387 Members | 3,787 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,387 software developers and data experts.

right alignment of text in the text box.

Hi

I need the text in the textbox should be right aligned and i used
style="text-align:right;" in the input tag.With it the text gets right aligned but when the user clicks a particular textbox it doesnot show cursor there. So it creates inconvenience to the user since he doesnt understand which field he is entering into.
So do suggest some possible solution, i dont want to include javascript in the jsp so refrain from it . I tried all possible ways if there is any other way plz let me know.
Jan 11 '07 #1
27 9965
MMcCarthy
14,534 Expert Mod 8TB
Hi

I need the text in the textbox should be right aligned and i used
style="text-align:right;" in the input tag.With it the text gets right aligned but when the user clicks a particular textbox it doesnot show cursor there. So it creates inconvenience to the user since he doesnt understand which field he is entering into.
So do suggest some possible solution, i dont want to include javascript in the jsp so refrain from it . I tried all possible ways if there is any other way plz let me know.
I am moving this question to the HTML forum where you are more likely to get an answer.

ADMIN
Jan 11 '07 #2
acoder
16,027 Expert Mod 8TB
DIR=rtl is a possibility
Jan 11 '07 #3
AricC
1,892 Expert 1GB
DIR=rtl is a possibility
What is that? I'm not familiar. Is there any reason you don't want to include javascript. You are probably going to need some language other than HTML to give that control focus.
Jan 11 '07 #4
acoder
16,027 Expert Mod 8TB
What is that? I'm not familiar. Is there any reason you don't want to include javascript. You are probably going to need some language other than HTML to give that control focus.
Direction from right to left. Default is left to right. It's probably similar to text-align right, but I thought I'd suggest this if it helped.
Jan 11 '07 #5
acoder
16,027 Expert Mod 8TB
You shouldn't need javascript to give a control focus when the user clicks on it as mentioned by the OP. I don't know why he has that problem. If the user clicks on a text box, it should gain focus.
Jan 11 '07 #6
AricC
1,892 Expert 1GB
You shouldn't need javascript to give a control focus when the user clicks on it as mentioned by the OP. I don't know why he has that problem. If the user clicks on a text box, it should gain focus.
Lol I think you and I are confused. Inquisitive, are you attempting to add focus to a control? Or are you saying that when someone clicks on your textboxes the textboxes are not gaining focus? Please clarify.

Thanks,
Aric
Jan 11 '07 #7
Well yes on clicking the textbox its not gaining focus and that too in the case of right aligned text. It should however not happen but its happening.
Jan 12 '07 #8
drhowarddrfine
7,435 Expert 4TB
Direction from right to left. Default is left to right. It's probably similar to text-align right, but I thought I'd suggest this if it helped.
This is for those languages that read from right to left, such as Hebrew and Arabic, not for aligning text.

I'm giving my wife my computer and have wiped it clean to send it to her office so don't have any of my dev tools or links available so I'm slow to respond to everything right now.
Jan 12 '07 #9
drhowarddrfine
7,435 Expert 4TB
I just tested this and didn't find any problem with the cursor not appearing in the text box when clicked. You do mean <textarea> correct?
Jan 12 '07 #10
acoder
16,027 Expert Mod 8TB
This is for those languages that read from right to left, such as Hebrew and Arabic, not for aligning text.
Yeah, you're right. Sorry, my mistake. I should've asked before suggesting it.
Jan 12 '07 #11
acoder
16,027 Expert Mod 8TB
Well yes on clicking the textbox its not gaining focus and that too in the case of right aligned text. It should however not happen but its happening.
Perhaps you can give us your code. When I tested with a textbox, it worked fine in Firefox, probably IE too.
Jan 12 '07 #12
AricC
1,892 Expert 1GB
Inquisitive, please post your code something must be spelled incorrectly or some other over-sight. This is extremely odd behavior for a browser.
Expand|Select|Wrap|Line Numbers
  1. <input type="text" size="25" name="SomeDescriptiveName" />
Jan 12 '07 #13
Hi

well this is the code I am using and it is showing a strange behaviour.

<input type="text" name="quantities" id="quantities" size="13" maxLength="16" style="text-align:right;" value="<%=StringUtils.formatDecimal(m.getQuantity( i)) %>" onChange="javascript:calcQuantityTotal()" /><br/>


I have again confirmed by testing on my pc that the problem still persist.
Jan 15 '07 #14
drhowarddrfine
7,435 Expert 4TB
It is working for me in Firefox and IE7 so I can only assume the script stuff is messing it up.
Jan 15 '07 #15
acoder
16,027 Expert Mod 8TB
Hi

well this is the code I am using and it is showing a strange behaviour.

<input type="text" name="quantities" id="quantities" size="13" maxLength="16" style="text-align:right;" value="<%=StringUtils.formatDecimal(m.getQuantity( i)) %>" onChange="javascript:calcQuantityTotal()" /><br/>


I have again confirmed by testing on my pc that the problem still persist.
What is the code for calcQuantityTotal()? That must be the problem. Perhaps it contains an infinite loop or another problem?
Jan 15 '07 #16
Expand|Select|Wrap|Line Numbers
  1. function calcQuantityTotal(decPlaces) {
  2.         var total = 0;
  3.         if (document.forms[0].quantities.length == null) {
  4.             if (isNaN(parseFloat(document.forms[0].quantities.value))) {
  5.             } else {
  6.                 total = parseFloat(document.forms[0].quantities.value);
  7.             }
  8.         } else {  
  9.             for (var i = 0; i < document.forms[0].quantities.length; i++)  {
  10.                 if (isNaN(parseFloat(document.forms[0].quantities[i].value))) {
  11.                 } else {
  12.                     total = total + parseFloat(document.forms[0].quantities[i].value);
  13.                 }
  14.             }
  15.  
  16.         }    
  17.         document.forms[0].totalQuantity.enabled = true;
  18.         document.forms[0].totalQuantity.value = " " + total.toFixed(decPlaces);
  19.     } 
  20.  
this is the code for calculate Quantity .plz let me know if it is anyhow creating problem.
Jan 18 '07 #17
acoder
16,027 Expert Mod 8TB
Expand|Select|Wrap|Line Numbers
  1. function calcQuantityTotal(decPlaces) {
  2.         var total = 0;
  3.         if (document.forms[0].quantities.length == null) {
  4.             if (isNaN(parseFloat(document.forms[0].quantities.value))) {
  5.             } else {
  6.                 total = parseFloat(document.forms[0].quantities.value);
  7.             }
  8.         } else {  
  9.             for (var i = 0; i < document.forms[0].quantities.length; i++)  {
  10.                 if (isNaN(parseFloat(document.forms[0].quantities[i].value))) {
  11.                 } else {
  12.                     total = total + parseFloat(document.forms[0].quantities[i].value);
  13.                 }
  14.             }
  15.  
  16.         }    
  17.         document.forms[0].totalQuantity.enabled = true;
  18.         document.forms[0].totalQuantity.value = " " + total.toFixed(decPlaces);
  19.     } 
  20.  
this is the code for calculate Quantity .plz let me know if it is anyhow creating problem.
You are calling calcQuantity without any arguments/parameters, but the function itself expects a number for decimal places.
Jan 18 '07 #18
Expand|Select|Wrap|Line Numbers
  1. <input type="text" name="quantities" id="quantities" style="text-align:right" value="<%=StringUtils.formatDecimal(form.getQuantity(i), 2, Locale.US) %>"  onChange="javascript:calcQuantityTotal('2')"/><br/>

No , i dont think the problem lies there since I have tried with arguements as well.
Jan 19 '07 #19
acoder
16,027 Expert Mod 8TB
Expand|Select|Wrap|Line Numbers
  1. <input type="text" name="quantities" id="quantities" style="text-align:right" value="<%=StringUtils.formatDecimal(form.getQuantity(i), 2, Locale.US) %>"  onChange="javascript:calcQuantityTotal('2')"/><br/>

No , i dont think the problem lies there since I have tried with arguements as well.
calcQuantityTotal expects a number not a string, so you should use:
Expand|Select|Wrap|Line Numbers
  1. onChange="javascript:calcQuantityTotal(2)"
Jan 19 '07 #20
Atli
5,058 Expert 4TB
Im not expert on ASP but I would assume a function called like that would return a value?

All I see this function do is add a value to form[0].TotalQuantity
Jan 19 '07 #21
acoder
16,027 Expert Mod 8TB
Im not expert on ASP but I would assume a function called like that would return a value?

All I see this function do is add a value to form[0].TotalQuantity
That is not the problem. If you read the first post:
I need the text in the textbox should be right aligned and i used style="text-align:right;" in the input tag.With it the text gets right aligned but when the user clicks a particular textbox it doesnot show cursor there. So it creates inconvenience to the user since he doesnt understand which field he is entering into. So do suggest some possible solution, i dont want to include javascript in the jsp so refrain from it
the cursor doesn't show when the user clicks, which means there must be a problem in the javascript (most probably the page loads fine). Also, it may be JSP, not ASP.
Jan 19 '07 #22
The problem is not even with calQuantity('3') string or number passed as parameter. I tried with both options but this doesnot solve the problem.
Jan 31 '07 #23
acoder
16,027 Expert Mod 8TB
The problem is not even with calQuantity('3') string or number passed as parameter. I tried with both options but this doesnot solve the problem.
Ok, I've looked at your calcQuantity code again, and it seems that the problem is definitely with the javascript.

You cannot use document.forms[0].quantities[i].value, etc. because the quantities field cannot be an array. If you show the form HTML, I can suggest changes to this code that should work.
Jan 31 '07 #24
I didnot understand what u need as I am very new to all this , can u tell me in detail what do you want, so that I can provide u with and in return u can provide me solution since the problem is still persisting.
Feb 1 '07 #25
AricC
1,892 Expert 1GB
I didnot understand what u need as I am very new to all this , can u tell me in detail what do you want, so that I can provide u with and in return u can provide me solution since the problem is still persisting.
Post everything you have pertaining to this problem HTML + Server side code.
Feb 1 '07 #26
alxgr
1
add style='padding-right:1px' to your input tag
Apr 21 '07 #27
@alxgr
this solution perfectly works! Thanks a lot!
Sep 29 '11 #28

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

Similar topics

2
by: Wilhelm Kutting | last post by:
Hi is there a possibility to align text to the right in a form?
0
by: Laurence Nuttall | last post by:
I have four labels on a form. All have there textalign property set to Middle Right. If I align the labels using the alignment tool the labels are aligned to the right, but the text in the labels...
4
by: Sam | last post by:
Hi everyone I have a question regarding string format. If I want to write a set of numeric values from arrays to a text file with the "right alignment" format as below, can it be done?...
7
by: Earl | last post by:
Any known fixes for the wacky right-alignment bug in the WinForms datagrid (VS2003)? I've tried Ken's workaround...
1
by: Suresh Tri | last post by:
Hi, I was trying to overload concat operator ||(text,text) such a way that it behaves like Oracle. i.e. I want 'abc' || null to return 'abc' instead of null. I know that it is not the expected ...
2
by: Johann Robette | last post by:
Hi, I'm trying to call the array_to_string function like this : SELECT array_to_string(array, '~^~') --> it comes directly from the doc. I get this error msg : ERROR: parser: parse error at...
4
by: David Garamond | last post by:
What is "text + text" supposed to do right now? It doesn't seem very useful to me. What about making "text + text" as an equivalent for "text || text"? Most strongly-typed programming languages do...
18
by: ~john | last post by:
Sorry if this is a dumb question buy my CSS is pretty bad... but how do I get text to center vertically within a div tag? Here's my code below... the text is displaying on the far top-right. I...
1
by: wasif11 | last post by:
Hi All I need the text in the textbox should be right aligned and i used style="text-align:right;" in the input tag.With it the text gets right aligned but when the user clicks a particular...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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,...

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.