Submit login form via javascript function

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
dlee
Veteran Member
Posts: 168
Joined: 2020-04-14 00:21
Location: South Carolina, USA
Contact:

Submit login form via javascript function

Post by dlee » 2022-01-21 20:06

I would like to submit the login form via a javascript function. I replaced the form's submit button with my own button that calls the javascript function mysubmit(). The function submits the login form BUT almost instantly you see, at the top right of the index.php page, the words "You are not logged in" and it kicks you back to the login form. How can I make this work?
TD

/login.php:

Code: Select all

	<button type="button" class="btn btn-success" id="recaptcha_btn" onclick="mysubmit()">SUBMIT</button>
/hooks/header-extras.php (I added an id to the login form - id="login_form")

Code: Select all

	function mysubmit(){
	  document.getElementById("login_form").submit();
	}

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1709
Joined: 2018-04-01 10:12

Re: Submit login form via javascript function

Post by pbottcher » 2022-01-22 14:46

Hi,

you need to pass the signIn value in your submit.

So try to change

Code: Select all

	function mysubmit(){
	  	document.getElementById("login_form").submit();
	}

Code: Select all

	function mysubmit(){
		$j('form').append('<input name="signIn" style="display: none;" value=1>');
	  	document.getElementById("login_form").submit();
	}
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

dlee
Veteran Member
Posts: 168
Joined: 2020-04-14 00:21
Location: South Carolina, USA
Contact:

Re: Submit login form via javascript function

Post by dlee » 2022-01-22 16:41

THAT DID IT, THANK YOU !!!
TD

Post Reply