このHTMLとJavascriptのビットは、IE6、FF2、FF3で動作します。私はそれがまた、IE7で動作しない理由何らかの理由を見つけることはできませんが、this.selectedIndexは、常に人々があまりにもそれほど強く反対し文体物事を変更するには編集0<select>タグのthis.selectedIndexがIE7で動作しないのはなぜですか?
** 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に入ったことは今まで見たことがありません。通常、それは別の方法で付加されているか、関数に入れられています。 –
http://thedailywtf.com/Articles/OnClick-Does-What!.aspxをお伝えしますか? – Greg
2行のjavascript == 30行のフォーム検証コードですか? –