views:

47

answers:

3

I have an internal suggestion box application where all users can have the same username and password ..

so I'm doing an autologin with a jquery form submit.. this works great in FF and Chrome but in IE.. it populates the values in the user/password form fields.. does the submit.. and then just does it again over and over.. ( the application is bbPress from WordPress) ..thanks much

login form:

<input name="user_login" type="text" id="quick_user_login" size="13" maxlength="40" value="USER_NAME_HERE" />

<?php _e( 'Password' ); ?><br />
<input name="password" type="password" id="quick_password" size="13" maxlength="40" tabindex="2" value="PASSWORD_HERE" />

<input name="re" type="hidden" value="<?php echo $re; ?>" />

jquery:

<script>
$(document).ready(function(){ 
    jQuery("#loginform").submit();
});
</script>

Entire login form ( stock bbPress code):

<form class="login" method="post" id="loginform" action="<?php bb_uri( 'bb-login.php', null, BB_URI_CONTEXT_FORM_ACTION + BB_URI_CONTEXT_BB_USER_FORMS ); ?>">
    <p>
        <?php
    printf(
        __( '<a href="%1$s">Register</a> or log in - <a href="%2$s">lost password?</a>' ),
        bb_get_uri( 'register.php', null, BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_USER_FORMS ),
        bb_get_uri( 'bb-login.php', null, BB_URI_CONTEXT_FORM_ACTION + BB_URI_CONTEXT_BB_USER_FORMS )
    );
    ?>

    </p>
    <div>
        <label>
            <?php _e('Username'); ?><br />
            <input name="user_login" type="text" id="quick_user_login" size="13" maxlength="40" value="USER_NAME_HERE" />
        </label>
        <label>
            <?php _e( 'Password' ); ?><br />
            <input name="password" type="password" id="quick_password" size="13" maxlength="40" tabindex="2" value="PASSWORD_HERE" />
        </label>
        <input name="re" type="hidden" value="<?php echo $re; ?>" />
        <?php wp_referer_field(); ?>

        <input type="submit" name="Submit" class="submit" value="<?php echo esc_attr__( 'Log in &raquo;' ); ?>" tabindex="4" />
    </div>
    <div class="remember">
        <label>
            <input name="remember" type="checkbox" id="quick_remember" value="1" tabindex="3"<?php echo $remember_checked; ?> />
            <?php _e('Remember me'); ?>

        </label>
    </div>
</form>
+1  A: 

try this:

jQuery("#loginform").trigger("submit");

Just a guess.

madeinstefano
A: 

This may not be the ideal solution but its a working solution (at least for now). Create a submit button (if you already have one, you can skip that). Append it, click it, remove it. Should work in IE (and all other browsers).

$('input').attr('type', 'submit').css('display', 'none')
          .appendTo('#loginForm').click().remove();
John Strickler
A: 

So this is a page with the values pre-filled, to be posted automatically as soon as the page is loaded.

My one big question: Why are you using JQuery for this? This functionality can be done just fine with plain old javascript, and it'll be quicker (it won't have to load JQuery to work) and more reliable (it's a very old technique, so it'll work in any browser you can throw at it, as long as it's got javascript enabled of course!)

<form name='loginform'>
  .......
</form>
<script>
  document.forms['loginform'].submit();
</script>
Spudley