wood burning stoves 2.0*
The moose likes HTML, CSS and JavaScript and the fly likes Running Javascript when form posts back to user Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Running Javascript when form posts back to user" Watch "Running Javascript when form posts back to user" New topic
Author

Running Javascript when form posts back to user

Meghna Bhardwaj
Ranch Hand

Joined: Jun 08, 2007
Posts: 109
HI,

I have 2 drop down lists A and B. The drop down list B must only be activated when from drop down A option 1 is chosen (for all other options chosen list B must be inactive). I have implemented this by calling a js function when list A changes as below:


This works just fine, but there is one scenario where it does not. This happens when the user selects option 1 from list A - this enables list B and the user can select an option there too. However after processing the request when the form posts back, list A still shows option 1 selected - but list B is disabled. The user then needs to change list A and reselect option 1 only then list B becomes active. So I need to also run my js function when the form posts back everytime - does anyone know how I can do this?

Any help much appreciated.

Regards.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
I would have the server do this if I alreasy know that user selected values. I would not rely on the clientside code to fill it in.


But if you want to do something about it...you could do something like
Meghna Bhardwaj
Ranch Hand

Joined: Jun 08, 2007
Posts: 109
Thank you so much, just tried it ... works perfectly!

Regards.
 
GeeCON Prague 2014
 
subject: Running Javascript when form posts back to user