469,362 Members | 2,331 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,362 developers. It's quick & easy.

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 3829

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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by R.G. Vervoort | last post: by
2 posts views Thread by calfdog | last post: by
6 posts views Thread by TS | last post: by
3 posts views Thread by Disco-181 | last post: by
4 posts views Thread by Zeebra3 | last post: by
13 posts views Thread by monomaniac21 | last post: by
9 posts views Thread by unlikeablePorpoise | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.