下拉列表日期保存不变的写法

com.huanglq.util;
public class PublicOption{
public static String getNumSelOption(int from, int to, String val)
{
StringBuffer sb = new StringBuffer();
String szIdx = "";
String szVal = "";
if (val != null) szVal = val;
for (int i=from; i<=to; i++)
{
if (i<10) szIdx = "0"+i;
else szIdx = ""+i;
if (szIdx.equals(szVal) || szIdx.equals("0"+szVal))
sb.append(" <option value='"+szIdx+"' selected>"+i+"</option> \n");
else
sb.append(" <option value='"+szIdx+"'>"+i+"</option> \n");
}
return sb.toString();
}
}

页面的对应内容:
<tr>
<td height="30"><font color="#FF6600">*</font>出生日期:</td>
<td> <input name="birthday" type="hidden"><input name="birthdayYear" type="text" size="4" maxlength="4">年
<select name="birthdayMonth">
<% out.println(com.huanglq.util.PublicOption.getNumSelOption(1, 12, birthdayMonth)); %>
</select>

<select name="birthdayDay">
<% out.println(com.huanglq.util.PublicOption.getNumSelOption(1, 31, birthdayDay)); %>
</select>
日 </td>
</tr>
---------------------
上 面的在提交时用 的 ,做显示时要先从action获得entity类,然后就可以直接用entity类的属性来显示了
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值