dropdownlist获取值ddl并在上面使用它 [英] Dropdownlist get value out ddl and use it above
问题描述
表单有问题吗?因为当我把它放在评论中时,我收到了几个月的下拉列表,当我把它放在代码中时,他每个月打印一行。
我不是Java的专家,在表单和选择中使用Onchange是否正确?
int m = -1;
HTMLCode + =< form onchange = \window.open('availability.jsp?user = 99& clickeddate =+ dateFormat.format(today.getTime())+& month = + avail.getMaand()+','_ self')\;
HTMLCode + =< select onchange ='javascript:setMonth(\+ m +\);'>; (m = today.get(Calendar.MONTH); m <12; m ++){
if(month == m)
HTMLCode + =< option value =' + m +'selected> + maand_voluit [m] +< / option>;
else
HTMLCode + =< option value ='+ m +'> + maand_voluit [m] +< / option>;
}
HTMLCode + =< / select>;
HTMLCode + =< / form>;
亲切问候
您不指定月份的值
尝试这样:
int month = today.get(Calendar.MONTH);
HTMLCode + =< form onchange = \window.open('availability.jsp?user = 99& clickeddate =+ dateFormat.format(today.getTime())+& month = + avail.getMaand()+','_ self')\;
HTMLCode + =< select onchange ='javascript:setMonth(\+ m +\);'>; (int m = 0; m <12; m ++){
if(month == m)
HTMLCode + =< option value ='+ m + ; + maand_voluit [m] +< / option>;
else
HTMLCode + =< option value ='+ m +'> + maand_voluit [m] +< / option>;
}
HTMLCode + =< / select>;
HTMLCode + =< / form>;
I'm trying to make a dropdownlist of the months. When the user select a month, the javascript fills the setter with the chosen value. Now I want to use that value above. So I made a form around my select with the action 'Onchange' and use the getMaand to calls the chosen month.
Is there something wrong with the form? Because when I put this in comment, I get the dropdownlist with the months, when I put it in code, he prints every month in one line.
I'm not an expert in Java, is it correct to use Onchange in the form and in the select?
int m = -1;
HTMLCode += "<form onchange=\"window.open('availability.jsp?user=99&clickeddate="+dateFormat.format(today.getTime())+"&month=" + avail.getMaand() + "','_self')\"";
HTMLCode += "<select onchange='javascript:setMonth(\"" + m + "\");'>";
for (m=today.get(Calendar.MONTH); m<12; m++){
if(month == m)
HTMLCode += "<option value='" + m + "' selected>" + maand_voluit[m]+ "</option>";
else
HTMLCode += "<option value='" + m + "'>" + maand_voluit[m] + "</option>";
}
HTMLCode += "</select>";
HTMLCode += "</form>";
Kind regards
You don't specify a value for month
Try this:
int month = today.get(Calendar.MONTH);
HTMLCode += "<form onchange=\"window.open('availability.jsp? user=99&clickeddate="+dateFormat.format(today.getTime())+"&month=" + avail.getMaand() + "','_self')\"";
HTMLCode += "<select onchange='javascript:setMonth(\"" + m + "\");'>";
for (int m=0; m<12; m++){
if(month == m)
HTMLCode += "<option value='" + m + "' selected>" + maand_voluit[m]+ "</option>";
else
HTMLCode += "<option value='" + m + "'>" + maand_voluit[m] + "</option>";
}
HTMLCode += "</select>";
HTMLCode += "</form>";
这篇关于dropdownlist获取值ddl并在上面使用它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!