EasyUI Forum
April 20, 2024, 01:32:46 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: submit form with link button  (Read 6075 times)
frankz
Newbie
*
Posts: 16


View Profile
« on: November 18, 2017, 02:09:17 AM »

how can you use the link button to submit a form without ajax?
because i have problems using ajax.
If I use the classic
Code:
<input type="submit" value="Submit">
works the post variables are sent, but if I use
Code:
<a href="controllers/login.php" class="easyui-linkbutton" onclick="$('#flogin').submit();" style="width:80px">Submit</a>
the variables they are not sent or read.

code HTML index.php

Code:
<body>
<div id='win'>

    <form id="flogin" action='controllers/login.php'  method="post">
                <div style="margin-bottom:20px ; margin-top:20px" >
                    <input id="user"  type="text" name="utente">
                </div>
                <div style="margin-bottom:20px">
                    <input id="pwd" type="password" name="password">
                </div>
                <input type="hidden" id="dbinuso" value="frasema" />
   <a href="javascript:void(0)" class="easyui-linkbutton" onclick="sublogin()" style="width:80px">Submit</a>

          
</form>

</div>
<script type="text/javascript" src="js/login.js"></script>    
</body>
where #win is an window

code JAVASCRIPT login.js
Code:
function sublogin(){
$('#flogin').form('submit',{
success:function(data){
   window.location.href = 'controllers/login.php';
  }
})

code PHP login.php
Code:
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<?php 
echo ($_POST['utente']);

?>


PAGINA 'login.php'
</body>
</html>
you only see:  PAGINA 'login.php'

can anyone help me find a solution with or without ajax?
« Last Edit: November 18, 2017, 08:05:45 AM by frankz » Logged
jarry
Administrator
Hero Member
*****
Posts: 2262


View Profile Email
« Reply #1 on: November 18, 2017, 08:41:11 AM »

Please remove the 'href' or set the 'ajax' property to false to submit the form without ajax.

Code:
<a href="javascript:;" class="easyui-linkbutton" onclick="$('#flogin').submit();" style="width:80px">Submit</a>
or
Code:
$('#flogin').form('submit',{
  ajax: false
});
Logged
frankz
Newbie
*
Posts: 16


View Profile
« Reply #2 on: November 18, 2017, 08:53:45 AM »

thanks, now I try.
I would like to use the link button before it checks.
Logged
frankz
Newbie
*
Posts: 16


View Profile
« Reply #3 on: November 18, 2017, 09:17:11 AM »

I tried, but they did not work.

the first and the second solution  works partially because it does not send me to the "controllers / login.php" page and reload
 the same page.

I should send the "login.php" data form for the user's verification in the DB and chase the main page (of course with login control in the open session)
« Last Edit: November 18, 2017, 09:50:50 AM by frankz » Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!