Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


shraddha
setText()
1 Answer(s)      6 years ago
Posted in : Framework



Advertisement
View Answers

October 18, 2008 at 4:50 PM


Hi friend,

Code to solve the problem :


<%@ page import="java.text.DecimalFormat"%>
<%
double value1 = 100.10;
double value2 = 100.23;
%>
<%!
public static String setText(double d) {
DecimalFormat fmt = new DecimalFormat("0.00");
String string = fmt.format(d);
return string;
}
%>
<HTML>
<head>
</head>
<BODY BGCOLOR="LIGHTYELLOW">
<FORM NAME="form" METHOD="GET" ACTION="">
<br><br>


<BR>

<TABLE CELLSPACING=5 CELLPADDING=5 BGCOLOR="LIGHTBLUE" COLSPAN=2 ROWSPAN=2 ALIGN="CENTER">
<tr><td></td><td><input type="text" name="text1" value="<%=setText(value1)%>"></td></tr>
<tr><td></td><td><input type="text" name="text2" value="<%=setText(value2)%>"></td></tr>
</table>

</FORM>
</BODY>
</HTML>

Thanks


Related Tutorials/Questions & Answers:
Advertisements
 

 

 

DMCA.com