473,324 Members | 2,179 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Dynamically setting query string with <select> onclick() handler

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
Jul 23 '05 #1
2 11710
Lee
Aaron C said:

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.


If the action of your form is "thispage.cfm" and the method is "get",
then all you need for the onchange handler is "this.form.submit()".
Normal form handling will set the query string for you.

Jul 23 '05 #2
Aaron C <ag********@comcast.net> wrote in message news:<mr********************@comcast.com>...
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


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.
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Hal Vaughan | last post by:
I have a sample script from a book ("Beginning JavaScript" by Paul Wilton) that removes or adds a choice to a <SELECT> element. The <FORM> is form1 and the <SELECT> is theDay. The example uses...
2
by: Mad Scientist Jr | last post by:
I'm trying to get javascipt select all items in a HTML form <SELECT> control and submit the form to an asp.net page. For some reason when the link is clicked, you can see the items all get...
2
by: Joachim Bauer | last post by:
I'm using the code below to display a menu that opens when the mouse goes over the main menu item (try it in your browser to understand the behaviour). It uses "position:absolute" and a switch...
4
by: Bart van Deenen | last post by:
Hi all I have a script where I dynamically create multiple inputs and selects from a script. The inputs and selects must have an associated onchange handler. I have the script working fine on...
6
by: Omar | last post by:
Hi, In a JSP I have the next: .... codigo = "<select name='" + nombre + "'>\n<option selected value='default'>Escoge</option><option value='todos'>Todos</option>"; if (miRS != null) while...
6
by: joseph.lindley | last post by:
Forgive me for I am a bit of a web-dev novice - but I'm not doing too bad. I'm currently working with a bit of javascript to dynamically add <option>s into a select box. My code currently works...
1
by: frey | last post by:
i tried to create a dropdown menu and use the option as a control to change content inside another text area the code is like this: <select name="xxxx"><option onclick="changeunitprice(29.87)"...
4
by: luftikus143 | last post by:
Hi there, I have a nasty little problem, as so often, only with IE. Here is an screenshot to better illustrate the problem. http://geodata.grid.unep.ch/screenshot13.png The map is clickable (to...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.