473,406 Members | 2,705 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,406 software developers and data experts.

onChange problem

Hi,

Could you please tell me what am I doing wrong in the next sentence?

<select name='id' onChange="window.location='dePaso.jsp?nombre=id&va lor="+this.options[this.selectedIndex].value+"'">

TIA
Jul 23 '05 #1
4 9415
Omar wrote:
Could you please tell me what am I doing wrong in the next sentence?


http://www.cs.tut.fi/~jkorpela/forms/navmenu.html

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Jul 23 '05 #2
Lee
Omar said:

Hi,

Could you please tell me what am I doing wrong in the next sentence?

<select name='id'
onChange="window.location='dePaso.jsp?nombre=id&v alor="+this.options[this.selectedIndex].value+"'">


You want (this.options[this.selectedIndex].value) to be evaluated
at the time that the onchange handler fires.

As written, it is evaluated at the time that you define the handler.
Try:

onchange="window.location=this.options[this.selectedIndex].value"

Jul 23 '05 #3
Omar wrote:
Hi,

Could you please tell me what am I doing wrong in the next sentence?

<select name='id' onChange="window.location='dePaso.jsp?nombre=id&va lor="+this.options[this.selectedIndex].value+"'">
TIA


Those double-quotes bounding the onchange handler string go around the
*entire* string; the singles are the ones you need to delimit the
literal part of the url (and discontinue, to insert a variable):

<select name="id"
onChange="window.location='dePaso.jsp?nombre=id&va lor='+this.value">

Select.value is pretty ubiquitous these days, someone will correct me
if that's inaccurate.

Might want to hook up a button to do this, users are notorious for
fumbling listboxes...

Jul 23 '05 #4
DU
Omar wrote:
Hi,

Could you please tell me what am I doing wrong in the next sentence?

<select name='id' onChange="window.location='dePaso.jsp?nombre=id&va lor="+this.options[this.selectedIndex].value+"'">

TIA


1- name="id" is a very bad choice of name value. And id="name" is also a
bad choice of id value. name="name" and id="id" are also bad choices.
Using the same string to identify both the name and id attributes is
also a bad coding practice.

2- In your code, it is more robust to use
window.location.href =

3- I think you are not using quotes accordingly. How about:

onchange = "window.location.href = 'dePaso.jsp?nombre=id&amp;valor=' +
this.options[this.selectedIndex].value;">

4- You also need to escape "&" in the href/query string to avoid
validation problems and make sure you're not referring to a named
character entity reference.

So, I would recommend:

<select onchange = "window.location.href =
'dePaso.jsp?nombre=id&amp;valor=' +
this.options[this.selectedIndex].value;">

if id is related to the select, then you need to adjust your code
accordingly with this.id in the query string.

DU
--
The site said to use Internet Explorer 5 or better... so I switched to
Mozilla 1.7.6 :)
Jul 23 '05 #5

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

Similar topics

1
by: Covad | last post by:
Hi all, For some reason my change() function is only called when the page loads. I'd much rather it gets called when the select changes. Here's the code: window.onload = init; function...
2
by: Jeff | last post by:
Hi Everyone, I'm having a problem with onChange. The tag looks like: <input:text bean = "" name="X" label="Y" attributesText="onChange=\"clear()\""> </input:text> if i replace, onChange...
1
by: Christoph | last post by:
I'm trying to validate some HTML form elements when the user tabs out of each element. However, I'm having some problems. It appears that the order of events is onChange followed some time...
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...
2
by: DonD | last post by:
I have a form that allows a user to upload a file. When they select a file (onChange), I call a JS function that analyzes the filename for specific keywords and then populates a multiple select box...
4
by: Zeebra3 | last post by:
Here goes: I have a web form with several asp:dropdownlists, with which, when selection is changed I want to fire an event defined in some clientside js. The content of the clientside code is...
3
by: jab3 | last post by:
Hello. I"m new to this group, and to JavaScript in general, so please forgive me if I breach local etiquette. I'm trying to implement some client-side 'dynamic' validation on a form. I'm having...
10
by: david.bercot | last post by:
Hi, I have a big problem with a simple event : onchange !!! If I write this page : <html> <body> <form id="vu"> <input id="var01" name="var01" size="5" onchange="return false;"/> </form>...
5
by: subhodey | last post by:
Hello, I have a ColdFusion online application that has a page having 2 textboxes. Corresponding to these 2 textboxes I have a Custom tag in coldfusion where the textbox is defined by <input...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.