Here you can find the source of getMonthSelect(String selectName, String value, boolean hasBlank)
public static String getMonthSelect(String selectName, String value, boolean hasBlank)
//package com.java2s; public class Main { public static String getMonthSelect(String selectName, String value, boolean hasBlank) { StringBuffer sb = new StringBuffer(""); sb.append("<select name=\"" + selectName + "\">"); if (hasBlank) { sb.append("<option value=\"\"></option>"); }// www .j a v a2 s . co m for (int i = 1; i <= 12; i++) { if (!value.trim().equals("") && i == Integer.parseInt(value)) { sb.append("<option value=\"" + i + "\" selected>" + i + "</option>"); } else { sb.append("<option value=\"" + i + "\">" + i + "</option>"); } } sb.append("</select>"); return sb.toString(); } public static String getMonthSelect(String selectName, String value, boolean hasBlank, String js) { StringBuffer sb = new StringBuffer(""); sb.append("<select name=\"" + selectName + "\" " + js + ">"); if (hasBlank) { sb.append("<option value=\"\"></option>"); } for (int i = 1; i <= 12; i++) { if (!value.trim().equals("") && i == Integer.parseInt(value)) { sb.append("<option value=\"" + i + "\" selected>" + i + "</option>"); } else { sb.append("<option value=\"" + i + "\">" + i + "</option>"); } } sb.append("</select>"); return sb.toString(); } }