0
是否可以通过单击按钮从组合框中选择指定值。从组合框中选择指定值
是否可以通过单击按钮从组合框中选择指定值。从组合框中选择指定值
选项1:
假设你想要的值设置为你的下拉3名为 'SEL'
<input type="button" value="set to 3" onclick="document.getElementById('sel').value = 3" />
选项2:
如果要设置具体的文本(比如' myvalue')作为选定的显示文本(已经存在于下拉列表中),那么你可以使用循环
for (i=0;i<document.getElementById('sel').length;i++)
{
if ('myvalue' == document.getElementById('sel').options(i).text)
{
document.getElementById('sel').options(i).selected = true;
return;
}
}
你使用jQuery的? – 2011-02-16 05:32:56
我正在使用java和java脚本 – user608032 2011-02-16 05:37:07