dropdownlist获取值ddl并在上面使用它

编程入门 行业动态 更新时间:2024-10-28 17:25:33
本文介绍了dropdownlist获取值ddl并在上面使用它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我正在尝试制作这几个月的下拉列表。当用户选择一个月时,JavaScript将使用所选值填充设置器。现在我想使用上面的值。所以我用Onchange操作对我的选择做了一个表单,并使用getMaand来调用所选择的月份。

表单有问题吗?因为当我把它放在评论中时,我收到了几个月的下拉列表,当我把它放在代码中时,他每个月打印一行。

我不是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并在上面使用它

本文发布于:2023-10-28 23:58:37,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1538143.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:并在   使用它   dropdownlist   ddl

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!