| re: Dynamically setting query string with <select> onclick() handler
Aaron C <agchandler@comcast.net> wrote in message news:<mrWdnbnm19qZeAbcRVn-sA@comcast.com>...[color=blue]
> This is kindof a newbie question, so please bear with me...
>
> I need to pass the selected option of a <select> tag into a query
> string, so that the page is reloaded with the selected option already
> chosen. This will occur with the onclick() event hander, and the query
> string will be processed using a server-side technology. I'm just not
> sure how to word the "onclick" handler. Here's what I have:
>
> <select id="StartMonth" name="StartMonth" onchange="location.href =
> 'thispage.cfm?StartMonth=_______'">
>
> What is the correct wording to set the underlined portion to whatever
> was selected? I know it has to be done with JavaScript, since the
> decision is made on the client-side. Any help would be soooo appreciated.
>
> Thanks,
> Aaron[/color]
Well - you apparently worded the "onclick" handler - by renaming it
"onchange". Good start. :D
<select id="StartMonth" name="StartMonth"
onchange="if(v=options[selectedIndex].value)top.location='thispage.cfm?StartMonth='+v">
Nothing will happen if the user selects a 'dummy' option (with no
value - typically the top one). Are you sure you want to do this
without an intermediate step, like a button press? UI convention
generally frowns on 'no-mistake' selects. |