Hi
I am trying to but a function together whereby the user max a selection
and the selection appears in a box on the screen:
function goThere(){
var list = document.forms[0].toy1;
location.href=list.options[list.selectedIndex.value];
}
<select name=toy1 id=toy1 onchange="goThere(this);>
<option1. .....
<select name=toy2 id=toy2 onchange="goThere(this);>
<options>.....
for some reason it isn't working. Could someone steer me in the right
direction.
Greg 9 2628
Gregc. wrote:
Hi
I am trying to but a function together whereby the user max a selection
and the selection appears in a box on the screen:
function goThere(){
var list = document.forms[0].toy1;
location.href=list.options[list.selectedIndex.value];
}
<select name=toy1 id=toy1 onchange="goThere(this);>
<option1. .....
<select name=toy2 id=toy2 onchange="goThere(this);>
<options>.....
for some reason it isn't working. Could someone steer me in the right
direction.
Greg
Hi Greg,
You made a few mistakes:
1) illegal functioncall (no arguments)
In your functioncall you give 'this', but in your functiondefinition you do
not receive it, let alone do something with it.
It should be like this:
var num1 = 3;
var num2 = 2;
alert = multiply(num1,num2);
function multiply(n1,n2){
return n1*n2;
}
2) If you use selectedIndex on a select-element, it returns the index (a
number) of the onbe selected. NOT IT'S VALUE.
so:
var theList = document.forms["formnamehere"].selectnamehere;
var selInd = theList.selectedIndex;
var theVal = theList[selInd].value;
location.href=theVal;
That will of course only work if you:
- End your SELECT-elements (which you do not do in the shown code)
- Give each option a value.
3) You didn't give your options-elements a value.
I would also advise you to get a good Javascript book, it is all in there.
(O'Reilly's 'Javascript the Definitive Guide 4th edition' is a good one.
Regards,
Erwin Moller
alert = multiply(num1,num2);
typo: should be:
alert (multiply(num1,num2));
Regards,
Erwin
Erwin Moller wrote:
alert = multiply(num1,num2);
typo: should be:
alert (multiply(num1,num2));
What if you do want an alert box, and want to record the results on the
form.
Gregc. wrote:
Erwin Moller wrote:
alert = multiply(num1,num2);
typo: should be: alert (multiply(num1,num2));
What if you do want an alert box, and want to record the results on the
form.
If that is a question, please ask more clearly.
The multiply example was just to show you you need to pass arguments if a
functions expects them.
So multiply(2,3) is allright, but multiply() is not, because the
functiondefinition says it wants 2 arguments.
Regards,
Erwin Moller
Erwin Moller wrote:
So multiply(2,3) is allright, but multiply() is not, because the
functiondefinition says it wants 2 arguments.
Regards,
Erwin Moller
Thankyou. It was most helpful.
Greg
JRS: In article <44**********************@news.xs4all.nl>, dated Mon,
21 Aug 2006 13:14:40 remote, seen in news:comp.lang.javascript, Erwin
Moller <si******************************************@spam yourself.com>
posted :
> I would also advise you to get a good Javascript book, it is all in there. (O'Reilly's 'Javascript the Definitive Guide 4th edition' is a good one.
Have you reasons for not mentioning the 5th Edition, seen to be
described as "soon" on 2006-05-04 ?
<FAQENTRYTo avoid deluding the innocent into buying the 4th Edition if
they'd have preferred the 5th, ISTM that Sec 3.1 needs update.
--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/>? JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
Dr John Stockton wrote:
JRS: In article <44**********************@news.xs4all.nl>, dated Mon,
21 Aug 2006 13:14:40 remote, seen in news:comp.lang.javascript, Erwin
Moller <si******************************************@spam yourself.com>
posted :
>> I would also advise you to get a good Javascript book, it is all in there. (O'Reilly's 'Javascript the Definitive Guide 4th edition' is a good one.
Have you reasons for not mentioning the 5th Edition, seen to be
described as "soon" on 2006-05-04 ?
Hi John,
I haven't seen it yet on the shelfs over here.
That is the only reason. :-)
Next time I'll refer to 'latest edition' which is more safe. :-)
You made me curious: Is the 5th any good above the 4th?
I mean, worth buying if you have the 4th?
What do you think of it?
Regards,
Erwin Moller
>
<FAQENTRYTo avoid deluding the innocent into buying the 4th Edition if
they'd have preferred the 5th, ISTM that Sec 3.1 needs update.
JRS: In article <44**********************@news.xs4all.nl>, dated Wed,
23 Aug 2006 11:42:34 remote, seen in news:comp.lang.javascript, Erwin
Moller <si******************************************@spam yourself.com>
posted :
>Dr John Stockton wrote:
>>>I would also advise you to get a good Javascript book, it is all in there. (O'Reilly's 'Javascript the Definitive Guide 4th edition' is a good one.
Have you reasons for not mentioning the 5th Edition, seen to be described as "soon" on 2006-05-04 ?
>I haven't seen it yet on the shelfs over here. That is the only reason. :-) Next time I'll refer to 'latest edition' which is more safe. :-)
You made me curious: Is the 5th any good above the 4th? I mean, worth buying if you have the 4th? What do you think of it?
I've neither got not read it. I think I saw it in a shop, but have not
found any note I may then have taken. I'm not sure what Amazon, etc.,
or O'Reilly say on the Web; perhaps a broadbander would look?
As I don't have the 4th, I would not be able to say whether it would be
worth buying a second copy - depends on how rich one is.
A current Amazon page includes :-
Product Details:
Paperback 1018 pages (August 2006)
Publisher: O'Reilly
Language: English
ISBN: 0596101996
Category(ies): Computers & Internet
Other Editions: Paperback
That's not the ISBN of the 4th, but higher.
Page http://www.davidflanagan.com/javascript5/ exists,
--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME. ©
Web <URL:http://www.merlyn.demon.co.uk/- FAQish topics, acronyms, & links.
I find MiniTrue useful for viewing/searching/altering files, at a DOS prompt;
free, DOS/Win/UNIX, <URL:http://www.idiotsdelight.net/minitrue/>
Dr John Stockton said the following on 8/24/2006 8:23 AM:
JRS: In article <44**********************@news.xs4all.nl>, dated Wed,
23 Aug 2006 11:42:34 remote, seen in news:comp.lang.javascript, Erwin
Moller <si******************************************@spam yourself.com>
posted :
>Dr John Stockton wrote:
>>>I would also advise you to get a good Javascript book, it is all in there. (O'Reilly's 'Javascript the Definitive Guide 4th edition' is a good one. Have you reasons for not mentioning the 5th Edition, seen to be described as "soon" on 2006-05-04 ?
>I haven't seen it yet on the shelfs over here. That is the only reason. :-) Next time I'll refer to 'latest edition' which is more safe. :-)
You made me curious: Is the 5th any good above the 4th? I mean, worth buying if you have the 4th? What do you think of it?
I've neither got not read it. I think I saw it in a shop, but have not
found any note I may then have taken. I'm not sure what Amazon, etc.,
or O'Reilly say on the Web; perhaps a broadbander would look?
29.69 Used to 32.99 New US Dollars is what is listed on Amazon and
linked to by the URL you give:
Page http://www.davidflanagan.com/javascript5/ exists,
That URL links to the information above.
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Russ |
last post by:
Hi,
I have found myself wanting to use an HTMLSelect control instead of a
DropDownList so that I can programatically set the item colours in the list
(not possible with DropDownList due to...
|
by: JohnSouth104 |
last post by:
Hi
I want to warn the user that changing the selected item in a pull-down
will clear some data he has already entered in a file download box.
I've tried using confirm() to return true or false...
|
by: Markus McGee |
last post by:
Hi all,
I have a quick question...I believe. On my web page, call it page A, I
have a drop downlist with runat server enabled. When the drop downlist
change event occurs it repopulates a...
|
by: rodchar |
last post by:
Hey all,
I was wondering againg...on my ASP.NET app I have a drop down list. I've set
the control to AutoPostBack=True. When I run this app, I select something out
of the drop down list and the...
|
by: genojoe |
last post by:
I have a combobox control on the form. When the user makes a change, I want
to validate a condition before permitting the change. If the condition is
not met, I want to return the ComboBox text...
|
by: Michel Lapointe |
last post by:
Hello,
I would like to know if there is an event for the Datagridview control
that is trigger before the selection change and is cancelable.
I'm currently using the SelectionChanged event...
|
by: Simon |
last post by:
Dear reader,
The syntax for the VBA code to change the RowSource of a Master Report is:
Me.RowSource = "TableOrQueryName"
|
by: Jure Bogataj |
last post by:
Hi all!
I have a problem (performance issue) with listview. I have implemented an
ItemSelectionChange on my listview and put some code in it (I build some
toolbar based on selection and update...
|
by: =?Utf-8?B?U2F0aXNo?= |
last post by:
C#, ASP.NET
Q: Have a formview, with a dropdownlist which is bound to a column. This
dropdownlist has a datasource of DataSet type. Now my objective is, on
Selection Changed of this DropdownList,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
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...
|
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,...
|
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...
|
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...
|
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...
| |