这一点的HTML和Javascript工作在IE6,FF2和FF3。我找不到任何理由为什么它不应该在IE7工作也行,不过this.selectedIndex总是返回0为什么this.selectedIndex无法在IE7上使用<select>标签?
** in javascript file
function onTypeChange()
{
alert($('type_id').selectedIndex);
if ($('type_id').selectedIndex != 0)
{
Element.update('chosenType', this.options[this.selectedIndex].text);
Form.Element.enable('go_button');
} else {
Element.update('chosenType', 'Selected Type');
Form.Element.disable('go_button');
}
}
** in html
<select class="hosp_select_buttons selectbox" id="type_id" name="type[id]"
onchange="onTypeChange();">
<option value="">Please select</option>
<option value="1594">Ambulatory Surgical Center</option>
<option value="1595">Birthing Center</option>
<option value="1596">Comprehensive Outpatient Rehabilitation Facilities</option>
<option value="1597">Drug Abuse Treatment Program</option>
<option value="1598">Mammography</option>
<option value="1599">Narcotic Treatment Program</option>
<option value="1600">Outpatient Physical Therapy</option>
<option value="1601">Private Home Care Provider</option></select>
**编辑改变风格的东西人反对如此强烈过。警告仍然表示在更改选择框后selectedIndex为0。该代码已经并且仍然可以在除I.E以外的所有浏览器中使用。 7
是否有任何的是JS的评价?我从来没有见过那么多的JS投入onchange。通常情况下,它是附加的或放入一个函数。 – 2009-04-29 18:48:38
提醒您http://thedailywtf.com/Articles/OnClick-Does-What!.aspx? – Greg 2009-04-29 18:53:21
因为2行javascript == 30行表单验证码? – 2009-04-29 20:13:22