473,382 Members | 1,726 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,382 software developers and data experts.

calling 2 functions onchange

<select name="ddlProfiles"
onchange="location.href=frmProfiles.ddlProfiles.op tions[selectedIndex].value;addOption_list()">

Is it possible to call 2 different functions using the onChange event
from a selectbox? What I have here isn't working - addOption_list()
never gets called.

Thanks

Nov 9 '06 #1
2 4037

shankwheat wrote:
<select name="ddlProfiles"
onchange="location.href=frmProfiles.ddlProfiles.op tions[selectedIndex].value;addOption_list()">

Is it possible to call 2 different functions using the onChange event
from a selectbox? What I have here isn't working - addOption_list()
never gets called.

Thanks
Well, your problem isn't calling 2 different functions from the
onchange event. Look closely - the first thing you're doing is
inducing a page reload, so the page reloads and basically wipes clean
all javascript state. You basically start from scratch. You've got a
couple of options here...

1. store state in a cookie, which your script reads on window load,
though some users have cookies turned off;
2. try to avoid reloading your page, through Ajax or some other
technique;
3. do your addOption_list() in your window.onload handler, assuming
it's something you always want to do no matter what page contents you
have;
4. sending a command across reload as an URL parameter
(http://myurl.com/?cmd=addOption_list) that you read in your
window.onload handler using code like var args =
window.location.search.split('&');

probably other options here as well, but basically you're stepping into
advanced javascript terrain here, where you're preserving session
information across page loads. Lots of good stuff out there in
Google-land on this; front-end devs have some quite sophisticated
techniques for doing this sort of thing, but it's a huge field out
there that deserves some general study.

-David

Nov 9 '06 #2
shankwheat scribed:
><select name="ddlProfiles"
onchange="location.href=frmProfiles.ddlProfiles.o ptions[selectedIndex].value;addOption_list()">

Is it possible to call 2 different functions using the onChange event
from a selectbox? What I have here isn't working - addOption_list()
never gets called.
Your telling the page to reload, and when it does, it's not going to see the
second function. Can you run addOption_list() before the location.href?
--
Ed Jay (remove 'M' to respond by email)
Nov 10 '06 #3

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

Similar topics

10
by: R.G. Vervoort | last post by:
I am using a javafunction (onclick in select) in which i am calling a function in php (thats why i send this to both php and javascript newsgroups). in the onclick i call the function...
2
by: calfdog | last post by:
Hello, Does anyone know a workaround for calling fireEvent. With the latest from Microsoft OS XP2 and Hot fixes to IE it now gives an "access denied" error in Python when called. Here is what...
6
by: TS | last post by:
Does anyone know if the Mac Browsers (IE5 / Safari) support anonymous functions or lambda functions? Ive been trying to get a site working with the Mac browsers and just cant get it to work. Here...
3
by: Disco-181 | last post by:
Hi, I have a script which isn't working in Mozilla based browser for some reason. I'm trying to run two functions from the body onload tag and it simply isn't happening. I have a cascading...
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...
2
by: Tyler | last post by:
Hi all, I am using some components from a JS library (scriptalicious), where callback functions are arguments to the constructors of the components like so: someClass x (name) { this.name =...
13
by: monomaniac21 | last post by:
hi i want to be able to trigger a javascript style popup alert in php (i want a message displayed on the actual page) is this possible?
9
by: unlikeablePorpoise | last post by:
I would like to have an HTML dropdown list where each selection calls a method. The following code doesn't work, but it I hope it gives the idea of what I'm trying to do: <FORM NAME="frm">...
22
by: DL | last post by:
Hi, What I wanted to do is to call a function from a newly created element. But it stumbled me. Here's the line that references the newly created element and I used the alert function for...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.