Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

Q1025 How can I pass the value of the selected option to the next page as part of the HREF property of a text link?

irt.org | Knowledge Base | JavaScript | Link | Q1025 [ previous next ]

Q1025 How can I pass the value of the selected option to the next page as part of the HREF property of a text link?

Use the following:

<SCRIPT LANGUAGE="JavaScript"><!--
function getValue(url) {
    return (url.indexOf('?') > -1 ? url.substring(0,url.indexOf('?')) : url) +
           '?' + escape(document.myName.mySelect.options[document.myName.mySelect.selectedIndex].value);
}
//--></SCRIPT>

<FORM NAME="myName">
<SELECT NAMe="mySelect">
<OPTION VALUE="123">first
<OPTION VALUE="234">second
<OPTION VALUE="345">third
</SELECT>
<FORM>

<A HREF="http://www.irt.org/index.htm" onClick="this.href=getValue(this.href)">irt.org</A>

Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.