Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to right-justify input objects in a form? 1

Status
Not open for further replies.

dove85

MIS
Aug 8, 2001
19
US
Your help would be appreciated.

1) How to line up (right justify) these numbers?
2) If "13.5" is the value, I want to display "13.50".
I wrote some JavaScript functions to parse the input objects as strings and then pad with zeors. Is there a better way to handle it?
3) I usually have problems displaying the "result of calculations" in proper format (9,999.90). I put the formulas in some JS functions, and use onFocus/onBlur to activate them. Is there a better way?

total_cost = unit_price * qty
open_qty = qty - rec_qty + ret_qty

Thanks.
Dove85
-----------------------------------------


<HTML>
<BODY>
<FORM NAME=&quot;OrderedItemsForm&quot; METHOD=&quot;post&quot; ACTION=&quot;SUBMITxyz.jsp&quot;>
<TABLE>
<TR>
<TD CLASS=TEXTAREACELLGRAYSHADED ALIGN=LEFT>&nbsp</TD><TD>&nbsp</TD>
<TD CLASS=TEXTAREACELLGRAYSHADED ALIGN=RIGHT VALIGN=BOTTOM>Unit Price</TD>
<TD CLASS=TEXTAREACELLGRAYSHADED ALIGN=RIGHT VALIGN=BOTTOM>Total</TD>
</TR>
<TR>
<TD CLASS=TEXTAREACELLGRAYSHADED ALIGN=LEFT>Ordered Qty. :</TD>
<TD><INPUT CLASS=INPUTCELL TYPE=&quot;text&quot; NAME=&quot;qty&quot; SIZE=&quot;20&quot;></TD>
<TD><INPUT CLASS=INPUTCELL TYPE=&quot;text&quot; NAME=&quot;unit_price&quot; SIZE=&quot;20&quot;></TD>
<TD><INPUT CLASS=INPUTCELL TYPE=&quot;text&quot; NAME=&quot;total_cost&quot; SIZE=&quot;20&quot;></TD>
<TR>
<TD CLASS=TEXTAREACELLGRAYSHADED ALIGN=LEFT>Received Qty.:</TD>
<TD><INPUT CLASS=INPUTCELL TYPE=&quot;text&quot; NAME=&quot;rec_qty&quot; SIZE=&quot;20&quot;></TD>
<TD><INPUT CLASS=INPUTCELL TYPE=&quot;text&quot; NAME=&quot;unit_price_rec&quot; SIZE=&quot;20&quot;></TD>
<TD><INPUT readOnly CLASS=INPUTCELL TYPE=&quot;text&quot; NAME=&quot;total_cost_rec&quot; SIZE=&quot;20&quot;></TD>
</TR>
<TR>
<TD CLASS=TEXTAREACELLGRAYSHADED ALIGN=LEFT>Returned Qty:</TD><TD ALIGN=RIGHT><INPUT CLASS=INPUTCELL TYPE=&quot;text&quot; NAME=&quot;ret_qty&quot; SIZE=&quot;20&quot;></TD></TR>
</TR>
<TR>
<TD CLASS=TEXTAREACELLGRAYSHADED ALIGN=LEFT>Open Quanty:</TD><TD ALIGN=RIGHT><INPUT readOnly CLASS=INPUTCELL TYPE=&quot;text&quot; NAME=&quot;open_qty&quot; SIZE=&quot;20&quot;></TD>
</TR>
</TABLE>
</TD>
</TABLE>
</BODY>
</HTML>
 
1) I suppose you could, but it would be a slow code snippit, most likely.

2) & 3) could you post your code? theEclipse
eclipse_web@hotmail.com
**\\||It was recently discovered that research causes cancer in rats||//**
 
theEclipse,

I have already figured out 2) & 3) but would like very much to know how to do 1).

Thanks.
Dove85
 
dove

I would think that it would be pretty easy to right justify something in a textbox. I would think that ms would have a built in html attribute justify=right or something. oh well, you cant win all the time
Code:
var width=100;

function justify(box){
var siz=box.value.length;
tempwidth=width-siz;
str='';
for (i=0;i<tempwidth;i++){
str+=' ';
}
box.value=str;
}

you might have to play around with the width to get to the right spot

Code:
<input onblur=justify(this) value='' name=rjustified>
theEclipse
eclipse_web@hotmail.com
**\\||It was recently discovered that research causes cancer in rats||//**
 
I might be misunderstanding, but you can right align text in a text box using css...

<input type=&quot;text&quot; style=&quot;text-align: right;&quot; value=&quot;test&quot; />

This works fine in IE and NN6+, but in NN4.7 it will right align the textbox instead of the actual text.
 
well there you go theEclipse
eclipse_web@hotmail.com
**\\||It was recently discovered that research causes cancer in rats||//**
 
aperfectcircle,

THAT is what I have been looking for! Thank you very much.

theEclipse, thank you for your effort. I do appreciate your help.

Dove85

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top