dongya2578 2016-12-13 08:40
浏览 57

使用javascript和php进入另一个没有刷新页面的文本输入后自动提交文本输入

Here my code for multiple text input in looping:

<?php
while($row_markah = mysql_fetch_array($result_markah))
{
?>
    <input class="form-control" name="markah[]" value="<?php echo $rows_markah ['markah'];?>" onkeypress="return isNumberKey(event)" onchange="javascript: submit();">
<?php
}
?>

I want to auto submit first text input after go to next text input without submit button and without refresh the page.

Can someone help me to solve this problem?

Thank You.

  • 写回答

1条回答 默认 最新

  • donglv7097 2016-12-13 09:09
    关注

    You need to create a ajax call for your first input onBlur..you can take this and adapt as you need.

    $(document).ready(function() {
      $(".firstInput").blur(function() {
        $.ajax({
            method: "POST",
            url: "url you need to submit",
            data: { dataName: "dataValue" }
          })
          .done(function(response) {
            alert("Back from server");
            $(".secondInput").focus();
          });
      });
    });
    

    check this https://jsfiddle.net/ers5hx7p/ as well to help you understand how things work with jquery / ajax. hope that helps.

    评论

报告相同问题?

悬赏问题

  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了