Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q748 Is it possible to create a select form field menu which redirects to other pages without any "go" button?

You are here: irt.org | FAQ | JavaScript | Form | 8 | Q748 [ previous next ]

Yes:

<SCRIPT LANGUAGE="JavaScript"><!--
function goto_URL(object) {
    window.location.href = object.options[object.selectedIndex].value;
}
//--></SCRIPT>

<FORM>
<SELECT NAME="selectName" onChange="goto_URL(this.form.selectName)">
<OPTION VALUE="http://www.irt.org">irt.org
<OPTION VALUE="http://www.irt.org/script/faq.htm">JavaScript FAQ
</SELECT>
</FORM>

On some older browsers the onChange event handler does not trigger until the focus moves from the form field.

©2018 Martin Webb