jQuery Thickbox submit form issue

Hi, I am trying to:
1 - open a thickbox
2 - in thickbox, user enters user/pass
3 - details are processed, user logged in, then same details passed to secondary login form
4 - secondary login form needs to submit and process login to sub section of site

So I need step 4 to auto submit the form which has already been populated.

I have got to step 4 quite happily. I am using a thickbox, i am able to present the form, on click process form within thickbox and new form is presented. I did for a few brief seconds earlier have this working, but I have now tried so many different tweaks that I cant seem to get it to work again lol.

So, in header of the parent page I have the following:

 <script type="text/javascript">
  jQuery(function($){
    $('#login').submit(function(){ 
      $.post($(this).attr('action'), $(this).serialize(), function(html) { 
            $('#loginbox').html(html);
        });

      return false
    })
    $("#loginform").load(function(){
                        $("#loginform").submit();
                        });
  })
</script>

the first function serialises data from initial form, posts it and prints response 9second form) into the thickbox. The second form is then very simple html form, and I am trying to auto submit it using jQuery. Second form is:

<form id="loginform" method="POST" action="http://site.com/index.php" name="loginform"><table cellspacing="1" cellpadding="2" border="0" width="100%">
                          <tbody><tr>
                            <td width="46%" class="smalltext">Username:</td>
                            <td width="54%"><input type="text" class="logintext" value="USERNAME" name="loginemail" gtbfieldid="2"></td>
                          </tr>
                          <tr>
                            <td class="smalltext">Password:</td>
                            <td><input type="password" class="loginpassword" value="PASSWORD" name="loginpassword"></td>
                            </tr>
                          <tr>
                            <td class="smalltext">Remember Me:</td>
                            <td><input type="checkbox" value="1" name="rememberme"></td>
                          </tr>
                          <tr>
                            <td class="smalltext">&nbsp;</td>
                            <td><input type="submit" class="yellowbutton" value="Log in" name="Submit2" id="kayaklogin">                          </td>
                          </tr>
                        </tbody></table><input type="hidden" value="core" name="_m"><input type="hidden" value="login" name="_a"><input type="hidden" value="" name="querystring"></form>

I know I am missing something incredibly simple, but I cannot see the woods for the trees. And before its mentioned, I cant show you the actual page as its on a development server which has more security on it than you could dream of, opening it up would be mare. If it is going to drastically help, then I can probably post to a dev server somewhere…

Any help appreciated greatly, as my eyes have gone seriously crossed looking at this issue. :slight_smile:

like i said, couldnt see the woods for the trees, dead simple solution, just added this to the bottom of the form:

<img src="images/pixel_trans.gif" onload="document.forms.loginform.submit();">

Bingo, form submits on load.