EasyUI Forum
April 24, 2024, 01:03:17 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: [Please Help!] Submit form using linkbutton problem.  (Read 12480 times)
kg
Newbie
*
Posts: 9


View Profile
« on: March 03, 2014, 02:35:45 AM »

This is Submit form code
Index.php
Code:
    <form action="insert_data.php" method="post" name="ff" id="ff">
    <div style="margin:10px 0;"></div>
    <div class="easyui-panel" title="Please input data" style="width:800px;height:600px;padding:45px;">
        <div class="easyui-layout" data-options="fit:true">
            <div data-options="region:'north',title:'Input Data ',collapsible:false" style="height:125px;padding:10px">
                <table>
    <tr>
    <td>ID:</td>
    <td><input name="ID" type="text" class="easyui-validatebox"  size="15" data-options="required:true"></input></td>
    <td>&nbsp;</td>
    <td>Date:</td>
    <td><input name="date" class="easyui-datebox" size="15" data-options="required:true,formatter:myformatter,parser:myparser"></input>
<script type="text/javascript">
        function myformatter(date){
            var y = date.getFullYear();
            var m = date.getMonth()+1;
            var d = date.getDate();
            return y+'-'+(m<10?('0'+m):m)+'-'+(d<10?('0'+d):d);
        }
        function myparser(s){
            if (!s) return new Date();
            var ss = (s.split('-'));
            var y = parseInt(ss[0],10);
            var m = parseInt(ss[1],10);
            var d = parseInt(ss[2],10);
            if (!isNaN(y) && !isNaN(m) && !isNaN(d)){
                return new Date(y,m-1,d);
            } else {
                return new Date();
            }
        }
</script>
                    </td>
    </tr>
                </table>
            </div>
            </div>
        </div>
            <div style="text-align:center;padding:5px">
    <a href="javascript:void(0)" class="easyui-linkbutton" onclick="submitForm()">Submit</a>
    <a href="javascript:void(0)" class="easyui-linkbutton" onclick="clearForm()">Clear</a>
    </div>
    </div>
</form>   
<script>
function submitForm(){
$('#ff').form('submit');
}
function clearForm(){
$('#ff').form('clear');
}
</script>
server response is: "OK"
the problem is:
if the submit button is:
Code:
<input type="submit" value="Submit">
then form $POST send to insert_data.php shows ok and change to insert_data.php and show result, but skip easyui-validatebox checking.

if this submit  is:
Code:
<a href="javascript:void(0)" class="easyui-linkbutton" onclick="submitForm()">Submit</a>
then form easyui-validatebox checking is work and $POST is ok  , but cannot change to insert_data.php  and show result page

insert_data.php
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Resuit</title>
</head>

<body>

<?php
echo "<BR>"$_POST['id'];
echo 
"<BR>"$_POST['date'];
?>

</body>
</html>
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: March 04, 2014, 12:37:35 AM »

When using 'submit' method of form, you are submitting a form via ajax. When submit successfully, the 'success' callback function will be called. You need to determine what to do in this function.
Code:
$('#ff').form('submit', {
  success:function(data){
    //...
  }
});
Logged
kg
Newbie
*
Posts: 9


View Profile
« Reply #2 on: March 04, 2014, 07:04:28 PM »

OK !
Thank you for your reply !! Smiley
Logged
frankz
Newbie
*
Posts: 16


View Profile
« Reply #3 on: November 16, 2017, 07:46:03 PM »

I say that they are at the beginning.
I'm experiencing the same problem, but I can not figure out what to put in the function {date} {...} to send the data to the server-side php file.
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!