复制代码 代码如下:
function find_select(name)
{
var select = document.getElementsByName(name);
var find_str = document.getElementById('to_find_str').value;
if(select)
{
select = select[0];
var child = select.childNodes;
var can=false,text='',len=child.length,is_end=true;
for(var i=0;i<len;i++)
{
if(can)
{
text = child[i].text;
if( text &&
text.indexOf(find_str)!=-1)
{
//console.log(text);
child[i].selected = true;
var v = child[i].value;
select.value = v;
select.onchange(v);
is_end = false;
break;
}
}
if(child[i].selected)
can = true;
}
if(is_end)
alert('已没有匹配内容');
}
}
复制代码 代码如下:
<tr>
<td><?php echo $L_SpecialActivityIdentifier?></td>
<td>
<select name="Activity[Identifier]" id="Identifier" onchange="change_activity(this.value)">
<option value="">请选择</option>
<?php
foreach ($ActivityTypes as $Row ) {
echo '<option value="'.$Row['Identifier'].'" '.($Row['Identifier']==$Activity['Identifier']?'selected':'').'>'.$Row['Name'].'</option>';
}
?>
</select>
-- <input value='' id='to_find_str' size=16 style="text-align:center;" /><input value='find' onclick='find_select("Activity[Identifier]")' type=button />
</td>
</tr>
function find_select(name)
{
var select = document.getElementsByName(name);
var find_str = document.getElementById('to_find_str').value;
if(select)
{
select = select[0];
var child = select.childNodes;
var can=false,text='',len=child.length,is_end=true;
for(var i=0;i<len;i++)
{
if(can)
{
text = child[i].text;
if( text &&
text.indexOf(find_str)!=-1)
{
//console.log(text);
child[i].selected = true;
var v = child[i].value;
select.value = v;
select.onchange(v);
is_end = false;
break;
}
}
if(child[i].selected)
can = true;
}
if(is_end)
alert('已没有匹配内容');
}
}
复制代码 代码如下:
<tr>
<td><?php echo $L_SpecialActivityIdentifier?></td>
<td>
<select name="Activity[Identifier]" id="Identifier" onchange="change_activity(this.value)">
<option value="">请选择</option>
<?php
foreach ($ActivityTypes as $Row ) {
echo '<option value="'.$Row['Identifier'].'" '.($Row['Identifier']==$Activity['Identifier']?'selected':'').'>'.$Row['Name'].'</option>';
}
?>
</select>
-- <input value='' id='to_find_str' size=16 style="text-align:center;" /><input value='find' onclick='find_select("Activity[Identifier]")' type=button />
</td>
</tr>
标签:
js,下拉菜单
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
桃源资源网 Design By www.nqtax.com
暂无“js自动查找select下拉的菜单并选择(示例代码)”评论...