Submitting a form conditionally

I am looking for some implementation ideas.

A view has a dropdown. After selecting a value in the dropdown and
clicking a submit button, the form gets submitted and calls a method in
the view's controller. This method would display a table of data in the
same view depending upon the selection made in the drop down. This
works fine.

There is another case where in the dropdown in the view can have a value
preselected by using some cookies set on the browser. So now, even
without clicking the submit button, the above mentioned method in the
controller should be called and a table of data should be displayed
according to the default value selected in the dropdown. How can this be


Given you are looking for idea, here is a few:

- Have your controller check for the cookie, and run the required code
just as if the page had been submitted and return the desired result

- If it is an AJAX submit, then have an onload event which checks for
the cookie and does the submission via javascript once the page is

- Least preferred (I can't think of a scenario where I would actually
recommend this, but just in case): Have javascript check the cookie on
load, change the value of the select, and then submit the form.

Hope that has helped