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

Function not working

I am trying to create a script that will have a drop down menu and will load the web page selected .
For some reason my function doesnot load the web page selected on the drop down menu What i am doing wrong here?

Any help will be appreciated

This is the function :
function loadPage(){
var sel_idx = document.demo.menu.selectedIndex
var urlToLoad = document.demo.menu.options[sel_idx].value

location.href = urlToLoad
}
This is the code:

<FORM NAME="demo">
<SELECT NAME="menu" onChange="loadPage()">
<OPTION VALUE="default2.htm">web1
<OPTION VALUE="les.htm">web2
<OPTION SELECTED VALUE="Default.htm">web3
<OPTION VALUE="webpage4.htm">web4
<OPTION VALUE="webpage5.htm">web5
</SELECT>
</FORM>
Jun 9 '07 #1
1 1163
epots9
1,351 Expert 1GB
i've tested your script and it works for me, i think your problem is u forgot the enclose your script in the script tag.
[HTML]
<html>
<head>
<title>my site</title>
<script type="text/javascript">
function loadPage(){
var sel_idx = document.demo.menu.selectedIndex
var urlToLoad = document.demo.menu.options[sel_idx].value

location.href = urlToLoad
}
</script>
</head>
<body>
<FORM NAME="demo">
<SELECT NAME="menu" onChange="loadPage()">
<OPTION VALUE="default2.htm">web1
<OPTION VALUE="les.htm">web2
<OPTION SELECTED VALUE="Default.htm">web3
<OPTION VALUE="webpage4.htm">web4
<OPTION VALUE="webpage5.htm">web5
</SELECT>
</FORM>
</body>
</html>
[/HTML]
Jun 9 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: amit kumar | last post by:
I am calling a function which returns pointer to a map. The declaration of the map is map<int,vectxyz*>. vectxyz is a vector containing pointer to a class xyz. For map<int,vectxyz*>* p1 In the...
39
by: Randell D. | last post by:
Folks, I'm sure this can be done legally, and not thru tricks of the trade - I hope someone can help. I'm writing a 'tool' (a function) which can be used generically in any of my projects. ...
1
by: Julie May | last post by:
I have 90% of my function working and I know to get the next 10% it is justa matter of getting the quotations and the escaping quotations correct. Here is the portion that does work: <working...
0
by: serkan | last post by:
Guys, I am trying to get this password reset functionality wor for me but I am not successful at all. Please somebody help me. I get "Your password could not be reset - please try again later" so I...
1
by: den2005 | last post by:
Hi everybody, I am confused and still looking why this codes is not working. Can anyone notice or know why this code is not working? Thanks in advance. Code working: <form id="form1"...
19
by: thisis | last post by:
Hi All, i have this.asp page: <script type="text/vbscript"> Function myFunc(val1ok, val2ok) ' do something ok myFunc = " return something ok" End Function </script>
3
by: shyamg | last post by:
hi all, This javascript is working IE but not working in FIreFox, validating text fields. var dealerid = new keybEdit('abcdefghijklmnopqurstuvwxyz01234567890 ','Alpha-numeric input only.'); ...
10
by: SQACPP | last post by:
Hi, I try to figure out how to use Callback procedure in a C++ form project The following code *work* perfectly on a console project #include "Windows.h" BOOL CALLBACK...
3
by: BibhuAshish | last post by:
Hello guys i have one function which converts the ip/netmask into networkid/netmask and also it shows the message to user that his ip is changed to network id. but that function is working in...
7
by: =?Utf-8?B?SmVycnkgQw==?= | last post by:
I am using this code to get groups for a user and getting a error (5) on the GetAuthorizationGroups() function . There are two domains. This function works on the local domain but does not work...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
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
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
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,...
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...

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.