Hello,
On http://student.ugent.be/astrid/bewoners.php I got the problem that I
want Javascript to let my browser go to http://student.ugent.be/astrid/bewon...ginAcjaar=2002 when I
select 2002-03 in the form in the upper right corner (idem dito for the
other years).
My form is composed by:
<form method="post" action="bewoner s.php">
<select onchange="veran derAcjaar()" name="selecteer Acjaar">
<option>2001-02</option>
<option>2002-03</option>
<option>2003-04</option>
</select>
</form>
and my Javascript code (that I've placed in <head/>):
<script language="Javas cript" type="text/javascript">
function veranderAcjaar( ) {
var acjaar =
selecteerAcjaar .options[selecteerAcjaar .selectedIndex].value
location =
"http://student.ugent.b e/astrid/bewoners.php?be ginAcjaar=" + acjaar
}
</script>
What could be wrong with this code? It /seems/ right to me, but
apparently it isn't. The browser doesn't even seem to execute the
function :-s (hmm, my knowledge of Javascript doesn't seem that good :-/)
Any help would be appreciated,
greetings,
Mattias 8 7152
Mattias Campe <Ma************ **********@UGen t.be> writes: On http://student.ugent.be/astrid/bewoners.php I got the problem that I want Javascript to let my browser go to http://student.ugent.be/astrid/bewon...ginAcjaar=2002 when I select 2002-03 in the form in the upper right corner (idem dito for the other years).
I see two problems.
My form is composed by: <form method="post" action="bewoner s.php"> <select onchange="veran derAcjaar()" name="selecteer Acjaar"> <option>2001-02</option>
.... and my Javascript code (that I've placed in <head/>): <script language="Javas cript" type="text/javascript"> function veranderAcjaar( ) { var acjaar = selecteerAcjaar .options[selecteerAcjaar .selectedIndex].value
Problem one: You haven't declared the variable "selecteerAcjaa r".
Some browsers (most notably IE) automatically declare global variables
with the same name as named elements on the page. Other browsers
don't. Change this to
var selRef = document.forms[0].elements['selecteerAcjaa r'];
var acjaar = selRef.options[selRef.selected Index].text;
(or, preferably, pass the selRef as an argument to the function as
onchange="veran derAcjaar(this) ;" )
Problem two: notice the ".text" at the end instead of ".value". The
content of an option is the "text" property, not the "value"
property. The value is specified as
<option value="Value">t ext</option>
location = "http://student.ugent.b e/astrid/bewoners.php?be ginAcjaar=" + acjaar
I prefer
location.href = ...
And remember the semicolon at the end.
What could be wrong with this code? It /seems/ right to me, but apparently it isn't. The browser doesn't even seem to execute the function :-s (hmm, my knowledge of Javascript doesn't seem that good :-/)
Nor your knowledge of how to make browsers show error messages:
<URL:http://jibbering.com/faq/#FAQ4_43>
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
Lasse Reichstein Nielsen wrote: Mattias Campe <Ma************ **********@UGen t.be> writes:On http://student.ugent.be/astrid/bewoners.php I got the problem that I want Javascript to let my browser go to http://student.ugent.be/astrid/bewon...ginAcjaar=2002 when I select 2002-03 in the form in the upper right corner (idem dito for the other years).
I see two problems.
My form is composed by: <form method="post" action="bewoner s.php"> <select onchange="veran derAcjaar()" name="selecteer Acjaar"> <option>2001-02</option>
...
and my Javascript code (that I've placed in <head/>): <script language="Javas cript" type="text/javascript"> function veranderAcjaar( ) { var acjaar = selecteerAcjaar .options[selecteerAcjaar .selectedIndex].value
Problem one: You haven't declared the variable "selecteerAcjaa r". Some browsers (most notably IE) automatically declare global variables with the same name as named elements on the page. Other browsers don't.
Thanks for pointing me on this one, I also like my code most when it
doesn't have to presume anything about the used browser...
Change this to var selRef = document.forms[0].elements['selecteerAcjaa r']; var acjaar = selRef.options[selRef.selected Index].text; (or, preferably, pass the selRef as an argument to the function as onchange="veran derAcjaar(this) ;" )
Do you mean that I could just use the following with veranderAcjaar( this):
var acjaar = this.options[selRef.selected Index].text;
?
Problem two: notice the ".text" at the end instead of ".value". The content of an option is the "text" property, not the "value" property. The value is specified as <option value="Value">t ext</option>
ic location = "http://student.ugent.b e/astrid/bewoners.php?be ginAcjaar=" + acjaar
I prefer location.href = ...
done
And remember the semicolon at the end.
Indeed, forgot about it :-s What could be wrong with this code? It /seems/ right to me, but apparently it isn't. The browser doesn't even seem to execute the function :-s (hmm, my knowledge of Javascript doesn't seem that good :-/)
Nor your knowledge of how to make browsers show error messages: <URL:http://jibbering.com/faq/#FAQ4_43>
Wauw, thanks for all the help, that link is bookmarked :)! But,
unfortunately, it still doesn't work. When I use the Javascript console
from Firefox, it tells me:
Error: selRef has no properties
Source file: http://student.ugent.be/astrid/bewoners.php Line:25
I checked the faq you gave me and http://jibbering.com/faq/#FAQ4_13 uses
quiet the same syntax that you gave me, so I don't see a problem there.
I hope you could help me again a little bit further :).
For the completeness, here's the new code:
<script language="Javas cript" type="text/javascript">
function veranderAcjaar( ) {
var selRef = document.forms[0].elements['selecteerAcjaa r'];
var acjaar = selRef.options[selRef.selected Index].text;
location.href =
"http://student.ugent.b e/astrid/bewoners.php?be ginAcjaar=" + acjaar;
}
</script>
and:
<form method="post" action="bewoner s.php">
<select onchange="veran derAcjaar()" name="selecteer Acjaar">
<option>2001-02</option>
<option>2002-03</option>
<option>2003-04</option>
</select>
</form>
Greetings,
Mattias
Mattias Campe <Ma************ **********@UGen t.be> writes: For the completeness, here's the new code: <script language="Javas cript" type="text/javascript"> function veranderAcjaar( ) { var selRef = document.forms[0].elements['selecteerAcjaa r']; var acjaar = selRef.options[selRef.selected Index].text; location.href = "http://student.ugent.b e/astrid/bewoners.php?be ginAcjaar=" + acjaar; } </script>
and: <form method="post" action="bewoner s.php"> <select onchange="veran derAcjaar()" name="selecteer Acjaar"> <option>2001-02</option> <option>2002-03</option> <option>2003-04</option> </select> </form>
This code works for me in Opera. Ofcourse it assumes that the relevant
form is the first form on the page (forms[0]). If it isn't, it will fail.
That is why I recommended passing the select as an argument:
---
<script type="text/javascript">
function veranderAcjaar( selRef) {
var acjaar = selRef.options[selRef.selected Index].text;
location.href =
"http://student.ugent.b e/astrid/bewoners.php?be ginAcjaar=" + acjaar;
}
</script>
---
and:
---
<form method="post" action="bewoner s.php">
<select onchange="veran derAcjaar(this) ;" name="selecteer Acjaar">
<option>2001-02</option>
<option>2002-03</option>
<option>2003-04</option>
</select>
</form>
---
(Why the form, btw? You don't use it, since there is no way to submit
it. You can omit the form element entirely when you address the select
directly like this, unless you need the page to work in Netscape 4 too :)
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
"Mattias Campe" <Ma************ **********@UGen t.be> a écrit dans le message
de news:c5******** **@gaudi2.UGent .be... Lasse Reichstein Nielsen wrote: Mattias Campe <Ma************ **********@UGen t.be> writes:On http://student.ugent.be/astrid/bewoners.php I got the problem that I want Javascript to let my browser go to http://student.ugent.be/astrid/bewon...ginAcjaar=2002 when I select 2002-03 in the form in the upper right corner (idem dito for the other years).
I see two problems.
My form is composed by: <form method="post" action="bewoner s.php"> <select onchange="veran derAcjaar()" name="selecteer Acjaar"> <option>2001-02</option>
...
and my Javascript code (that I've placed in <head/>): <script language="Javas cript" type="text/javascript"> function veranderAcjaar( ) { var acjaar = selecteerAcjaar .options[selecteerAcjaar .selectedIndex].value
Problem one: You haven't declared the variable "selecteerAcjaa r". Some browsers (most notably IE) automatically declare global variables with the same name as named elements on the page. Other browsers don't.
Thanks for pointing me on this one, I also like my code most when it doesn't have to presume anything about the used browser...
Change this to var selRef = document.forms[0].elements['selecteerAcjaa r']; var acjaar = selRef.options[selRef.selected Index].text; (or, preferably, pass the selRef as an argument to the function as onchange="veran derAcjaar(this) ;" )
Do you mean that I could just use the following with veranderAcjaar( this): var acjaar = this.options[selRef.selected Index].text; ?
Problem two: notice the ".text" at the end instead of ".value". The content of an option is the "text" property, not the "value" property. The value is specified as <option value="Value">t ext</option>
ic
location = "http://student.ugent.b e/astrid/bewoners.php?be ginAcjaar=" + acjaar
I prefer location.href = ...
done
And remember the semicolon at the end.
Indeed, forgot about it :-s
What could be wrong with this code? It /seems/ right to me, but apparently it isn't. The browser doesn't even seem to execute the function :-s (hmm, my knowledge of Javascript doesn't seem that good :-/)
Nor your knowledge of how to make browsers show error messages: <URL:http://jibbering.com/faq/#FAQ4_43>
Wauw, thanks for all the help, that link is bookmarked :)! But, unfortunately, it still doesn't work. When I use the Javascript console from Firefox, it tells me: Error: selRef has no properties Source file: http://student.ugent.be/astrid/bewoners.php Line:25
I checked the faq you gave me and http://jibbering.com/faq/#FAQ4_13 uses quiet the same syntax that you gave me, so I don't see a problem there. I hope you could help me again a little bit further :).
For the completeness, here's the new code: <script language="Javas cript" type="text/javascript"> function veranderAcjaar( ) { var selRef = document.forms[0].elements['selecteerAcjaa r']; var acjaar = selRef.options[selRef.selected Index].text;
change the above line to:
var acjaar = selRef.options[selRef.selected Index].value;
location.href = "http://student.ugent.b e/astrid/bewoners.php?be ginAcjaar=" + acjaar; } </script>
and: <form method="post" action="bewoner s.php"> <select onchange="veran derAcjaar()" name="selecteer Acjaar"> <option>2001-02</option> <option>2002-03</option> <option>2003-04</option>
and these to:
<option value=2001>2001-02</option>
<option value=2002>2002-03</option>
<option value=2003>2003-04</option>
</select> </form>
Greetings, Mattias
Lasse Reichstein Nielsen wrote:
[...] This code works for me in Opera. Ofcourse it assumes that the relevant form is the first form on the page (forms[0]). If it isn't, it will fail. That is why I recommended passing the select as an argument: --- <script type="text/javascript"> function veranderAcjaar( selRef) { var acjaar = selRef.options[selRef.selected Index].text; location.href = "http://student.ugent.b e/astrid/bewoners.php?be ginAcjaar=" + acjaar; } </script> --- and: --- <form method="post" action="bewoner s.php"> <select onchange="veran derAcjaar(this) ;" name="selecteer Acjaar"> <option>2001-02</option> <option>2002-03</option> <option>2003-04</option> </select> </form>
I uses (this) and I also used the remark by Morris, because
?beginAcjaar="2 001-02" will not work, it has to be ?beginacjaar="2 001"
(stupid me :-/ ;) )
(Why the form, btw? You don't use it, since there is no way to submit it. You can omit the form element entirely when you address the select directly like this, unless you need the page to work in Netscape 4 too :)
Well, I thought that a <select> had to be surrounded by <form>, but as
this doesn't seem to be true, I just omitted it.
Really, thanks a lot for the help!
Greetings,
Mattias
Morris wrote: "Mattias Campe" <Ma************ **********@UGen t.be> a écrit dans le message
change the above line to: var acjaar = selRef.options[selRef.selected Index].value;
location.href = "http://student.ugent.b e/astrid/bewoners.php?be ginAcjaar=" + acjaar; } </script>
and: <form method="post" action="bewoner s.php"> <select onchange="veran derAcjaar()" name="selecteer Acjaar"> <option>2001-02</option> <option>2002-03</option> <option>2003-04</option>
and these to:
<option value=2001>2001-02</option> <option value=2002>2002-03</option> <option value=2003>2003-04</option>
Of course! How could I overlook that :-/
Really, thanks a lot for the help!
It works now: http://student.ugent.be/astrid/bewoners.php
Greetings,
Mattias
Donner un nom à votre formulaire (<form name="myform" ....>)
et var acjaar=myform.s elect..........
GR
Mattias Campe a écrit: Hello,
On http://student.ugent.be/astrid/bewoners.php I got the problem that I want Javascript to let my browser go to http://student.ugent.be/astrid/bewon...ginAcjaar=2002 when I select 2002-03 in the form in the upper right corner (idem dito for the other years).
My form is composed by: <form method="post" action="bewoner s.php"> <select onchange="veran derAcjaar()" name="selecteer Acjaar"> <option>2001-02</option> <option>2002-03</option> <option>2003-04</option> </select> </form>
and my Javascript code (that I've placed in <head/>): <script language="Javas cript" type="text/javascript"> function veranderAcjaar( ) { var acjaar = selecteerAcjaar .options[selecteerAcjaar .selectedIndex].value location = "http://student.ugent.b e/astrid/bewoners.php?be ginAcjaar=" + acjaar } </script>
What could be wrong with this code? It /seems/ right to me, but apparently it isn't. The browser doesn't even seem to execute the function :-s (hmm, my knowledge of Javascript doesn't seem that good :-/) Any help would be appreciated, greetings, Mattias
G Roydor wrote: Donner un nom à votre formulaire (<form name="myform" ....>) et var acjaar=myform.s elect..........
Merci beaucoup, mais j'ai déja une solution :)...
GR
Mattias Campe a écrit:
Hello,
On http://student.ugent.be/astrid/bewoners.php I got the problem that I want Javascript to let my browser go to http://student.ugent.be/astrid/bewon...ginAcjaar=2002 when I select 2002-03 in the form in the upper right corner (idem dito for the other years).
My form is composed by: <form method="post" action="bewoner s.php"> <select onchange="veran derAcjaar()" name="selecteer Acjaar"> <option>2001-02</option> <option>2002-03</option> <option>2003-04</option> </select> </form>
and my Javascript code (that I've placed in <head/>): <script language="Javas cript" type="text/javascript"> function veranderAcjaar( ) { var acjaar = selecteerAcjaar .options[selecteerAcjaar .selectedIndex].value location = "http://student.ugent.b e/astrid/bewoners.php?be ginAcjaar=" + acjaar } </script>
What could be wrong with this code? It /seems/ right to me, but apparently it isn't. The browser doesn't even seem to execute the function :-s (hmm, my knowledge of Javascript doesn't seem that good :-/) Any help would be appreciated, greetings, Mattias
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Lee Mundie |
last post by:
Hi there,
Simple problem here but can't seem to fix it!
Okay, I have a select list from which people choose avatars...
the list is option values ie. <option>Worm</option> <option>Frog</option>
etc etc and is in an include file...
where the word i.e. worm sources the image ..images/worm.gif - simple so
far...
|
by: Quinn |
last post by:
HI!
Have two from text fields named "odds" and "stake" where I enter numeric
values.
I want to have a text label named "returns" that is automatically updated
whenever any of these changes.
Here's my first try (I have cut this out from the form, named form_bet):
<input name="odds" type="text" id="odds" onChange="updateReturns();"
|
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 afterwards by onBlur. I believe this to be the
case because in my onChange script, if the validation fails,
I force focus back to the field element. However, the focus
still falls to the next field and not back to the field I tried to
force the...
|
by: aundro |
last post by:
Hello,
I've been looking on the web for a solution to this problem:
I create a set of checkboxes, and 2 buttons:
- one is labeled "All"
- the other is labeled "None"
Clicking "All" is supposed to check all the checkboxes, which it does
(that's not rocket science ;), but the 'onchange' event does not get
triggered.
|
by: charliefortune |
last post by:
Every time a field in an accounts form changes, an onChange =
"updateAmount()" executes this function -
function updateAmount(x){
var field = 'amount' + x;
var val = parseFloat(document.forms.field.value);
document.forms.totAmount.value = val;
}
the fields are called 'amount1', 'amount2', 'amount3' etc. and the
| |
by: donald |
last post by:
I have a function called populate which populate a select box. I need
it to run when a different select box value is chnage. So I need the
event onChange.
But i need to pass it two var to. how do i do this??
object.onchange = ..
What do I made it equal to for the above. if the typename = 'type1' and
itemname = 'item1'.
|
by: The Natural Philosopher |
last post by:
This is a nasty one and I can't see my way out of it.
I have a bunch of select statements in a form, and each select statement
has an onchange="do_something(this)" in it, and this works
nicely..except when there is only ONE OPTION in a given select.
It seems you cannot 'onchange' a single option!
Well, that is reasonable.
The trouble is I have no way of selecting it since the form itself is a
|
by: James007 |
last post by:
Hi everyone,
I am developing a web page for an embedded application. I created a text box for entering a value (only 1 byte long). The onchange event triggers correctly when I enter the value from a keyboard and press enter. However, it doesn't seem to fire when a javacript (a slider in this case) modifies the text box's value. I have tried:
document.getElementById("sd1").fireEvent("onchange"); and,...
|
by: colyn7 |
last post by:
I really can't see what's wrong in my code... the submit() onChange doesn't work..
I've tried..
<select name="ddlTestCenter" id="ddlTestCenter" style="width:180px" onChange="this.form.submit();">
it doesn't work...
<input type="hidden" name="hiddenopt" value="secret"> <select name="list" onChange="document.forms.submit();">
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |