shraddha
setText()
1 Answer(s)      4 years and 7 months ago
Posted in : Framework

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 Pages:

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.