functions, nesting and calling

functions, nesting and calling

Hi, I'm a super newbie, having been working at jquery for about two days now.

I have a question regarding the nesting and calling of functions.  I'll attempt to paint it in a fairly simple way.

I have a page that offers the user a few choices (its a game, so..) like attack or defend, what weapon to use.  It then loads two html <select>'s, each with a "commit" button.  The commit buttons are tied to (separate) functions that pass data to ajax.

The problem I have is that I'm getting buried in nested functions.  Does that make sense?  My code looks something like this:

  1. $(function() {
  2.       $('#choice1').click(function() {
  3.             //do some stuff
  4.       });
  5.       $('#choice2').click(function() {
  6.              //do some stuff
  7.        });
  8.       $('#choice3').click(function() {
  9.             //do some stuff, including creating the choices below, and their submit boxes
  10.             $('#subChoice1').click(function() {
  11.                   //do some stuff
  12.                   //now I need to go back to some kind of a nextFunction
  13.             });
  14.             $('#subChoice2').click(function() {
  15.                   //do some stuff
  16.                   //now I need to go back to some kind of a nextFunction
  17.             });
  18.       });  // end choice3
  19. });
When I get down to subChoice1 and 2, I don't seem to be able to just call upon another function unless it is nested beneath itself.

I hope that makes sense.  

Any pointers to get me headed in the right direction?  I'm hoping that there is a simple answer that I just haven't discovered yet.

Thanks!