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()
2 Answer(s)      6 years ago
Posted in : Framework



Advertisement
View Answers

October 18, 2008 at 4:22 PM


Hi friend,


<%

double value1 = 100.10;
double value2 = 100.23;
%>

<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="<%=value1%>"></td></tr>
<tr><td></td><td><input type="text" name="text2" value="<%=value2%>"></td></tr>
</table>

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

For any more problem visit to :

http://www.roseindia.net/

Thanks


October 18, 2008 at 4:48 PM


Hi friend,


Code to help in solving the problem :


<%@ page import="java.text.DecimalFormat"%>
<%
double value1 = 100.10;
double value2 = 100.23;
%>
<%!
public static String doubleToString2(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="<%=doubleToString2(value1)%>"></td></tr>
<tr><td></td><td><input type="text" name="text2" value="<%=doubleToString2(value2)%>"></td></tr>
</table>

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

Thanks


Related Tutorials/Questions & Answers:
Advertisements
 

 

 

DMCA.com