Title: Submit Form with Link Button
Post by: Punkerr on February 21, 2013, 03:40:32 PM
Hi guys. I have a little problem here: HTML:<div class="easyui-panel" style="width:167px"> <form id="ff" method="post"> <table> <tr> <td>User:</td> </tr> <tr> <td><input id="user" class="easyui-validatebox" type="text" name="user" required="true"></input></td> </tr> <tr> <td>Password:</td> </tr> <tr> <td><input id="password" class="easyui-validatebox" type="password" name="password" required="true"></input></td> </tr> </table> <div style="background:#fafafa;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> </form> </div> SCRIPT:$(function(){ $('#ff').form({ url:'log_validate.php', onSubmit:function(){ return $(this).form('validate'); }, success:function(data){ document.location.reload(true); $.messager.alert('Access', data, 'info'); } }); }); function submitForm(){ $('#ff').form('submit'); } function clearForm(){ $('#ff').form('clear'); } The form works perfectly with: <input type="submit" value="Submit">, but when I replaced with <a href="javascript:void(0)" class="easyui-linkbutton" onclick="submitForm()">Submit</a>... doesn't work. I searched all the forum topics and I found this solution: onClick="$('#ff').submit();", but it doesn't work either. Any idea anybody??
Title: Re: Submit Form with Link Button
Post by: stworthy on February 21, 2013, 06:34:50 PM
Calling $('#ff').submit() statement can submit the form normally. Another way to submit a form is to call 'submit' method of form plugin. The code below shows how to call 'submit' method. $('#ff').form('submit', { url:'log_validate.php', onSubmit:function(){ return $(this).form('validate'); }, success:function(data){ $.messager.alert('Access', data, 'info'); } });
Title: Re: Submit Form with Link Button
Post by: Punkerr on February 23, 2013, 12:39:05 PM
Thanks sworthy, this line was the solution: "Calling $('#ff').submit() statement can submit the form normally". I had not understood before, but now it's all clear. Here's my code: JSCRIPT $(function(){ $('#ff').form({ url:'log_validate.php', onSubmit:function(){ return $(this).form('validate'); }, success:function(data){ document.location.reload(true); } }); }); HTML <form id="ff" method="post"> <table> <tr> <td>User:</td> </tr> <tr> <td align="center"><input id="user" class="easyui-validatebox" type="text" name="user"></input></td> </tr> <tr> <td>Password:</td> </tr> <tr> <td align="center"><input id="password" class="easyui-validatebox" type="password" name="password" required="true"></input></td> </tr> <tr> <td align="center"><a href="javascript:void(0)" class="easyui-linkbutton" onclick="$('#ff').submit()">Submit</a></td> </tr> </table> </form> Now I have an "easyui-linkbutton" working :)
|