问题是这样的:
<script>
function $(id) { return document.getElementById(id); };
function settingsCallback(o) {
if ($('txtVer')) $('txtVer').value = o.ver;
if ($('txtMac')) $('txtMac').value = o.mac;
if ($('txtIp')) $('txtIp').value = o.ip;
if ($('txtSub')) $('txtSub').value = o.sub;
if ($('txtGw')) $('txtGw').value = o.gw;
if ($('txtProtecalType')) $('txtProtecalType').value = o.pt;
if ($('SProtecalType')) $('SProtecalType').value= JSON.parse(o.pt);
};
</script>
<select name=\"SProtecalType\" id="SProtecalType" size='1'>
<option value =\"0\">0:通用类型</option>
<option value =\"1\">1:902TCP</option>
<option value =\"2\">2:608UDP</option>
<option value =\"3\">3:608UDP CLI</option>
<option value =\"4\">4:APP UDP</option>
</select>参数已经传递过来了,我通过if ($('txtProtecalType')) $('txtProtecalType').value = o.pt;在一个文本框中调试的,就是无法选择列表,不会java真糟糕啊,请大神们赐教
<script>
function $(id) { return document.getElementById(id); };
function settingsCallback(o) {
if ($('txtVer')) $('txtVer').value = o.ver;
if ($('txtMac')) $('txtMac').value = o.mac;
if ($('txtIp')) $('txtIp').value = o.ip;
if ($('txtSub')) $('txtSub').value = o.sub;
if ($('txtGw')) $('txtGw').value = o.gw;
if ($('txtProtecalType')) $('txtProtecalType').value = o.pt;
if ($('SProtecalType')) $('SProtecalType').value= JSON.parse(o.pt);
};
</script>
<select name=\"SProtecalType\" id="SProtecalType" size='1'>
<option value =\"0\">0:通用类型</option>
<option value =\"1\">1:902TCP</option>
<option value =\"2\">2:608UDP</option>
<option value =\"3\">3:608UDP CLI</option>
<option value =\"4\">4:APP UDP</option>
</select>参数已经传递过来了,我通过if ($('txtProtecalType')) $('txtProtecalType').value = o.pt;在一个文本框中调试的,就是无法选择列表,不会java真糟糕啊,请大神们赐教
根据项目的值改变列表的选中项目
$('SProtecalType').value = o.pt;
根据项目索引号改变列表的选中项目
$('SProtecalType').selectedIndex = o.pt;要修改项目的值,循环$('SProtecalType').options数组
$('SProtecalType').options[i].text = 文字;
$('SProtecalType').options[i].value = 值;
不是$('SProtecalType')可以直接设置$('#SProtecalType').val(你要的值);
就是这个根据项目索引号改变列表的选中项目
$('SProtecalType').selectedIndex = o.pt;我再看看