|
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>
|
|
|
Copyright © 1996-2009 irt.org, All Rights Reserved.