2014-02-14 38 views
0

我的表格:腓后形式的onkeyup功能

<tfoot> 
     <form method="post" action="kategoriler.php"> 
    <tr> 
    <th>Select</th> 
    <th><input type="text" name="id" id="id" class="form-control" style="width:80px;" placeholder="#"></th> 
    <th>Image</th> 
    <th><input type="text" name="name" id="name" class="form-control" style="width:120px;" placeholder="Name"></th> 
    <th>Order</th> 
    <th><input type="text" name="Visibility" id="Visibility" class="form-control" style="width:120px;" placeholder="Visibility"></th> 
    <th>Date</th> 
    <th>Edit</th> 
    </tr> 
    </form> 
    </tfoot> 

我想我怎么能发送此表单值后用JSON和功能的onkeyup这个值?

+0

与onkeyup事件?非常糟糕的主意 –

+0

你的想法是什么?我不擅长jquery –

+0

你可以使用[jQuery.ajax()](http://api.jquery.com/jQuery.ajax/) – Jai

回答

1

该作品增添KEYUP功能对所有输入型的形式

$('form input:text').keyup(function(){ 
     var data = $("form").serialize(); 
     $.ajax({ 
     url: 'kategoriler.php', 
     data: data, 
     dataType:'json', 
     type:'POST', 
     async:false, 
     success: function(data) { 
      alert('submitted'); 
     } 
}); 

如果你想添加KEYUP在一个特定的输入类型,然后只是更换

$('form input:text').keyup(function(){ 

随着

$('#id').keyup(function(){ 
+0

中描述的那样得到相同的值。我怎么能得到这个值在kategoriler.php例如我发送的名字,但我不能把这个名字其他页面 –

+1

使用$ _POST ...像$ all_input_values = $ _POST然后$ all_input_values ['id']这会得到你的id值..其他 –

1

使用jQuery AJAX为:

$(document).keydown(function(e) { 
    $.ajax({ 
       type: "POST", 
       dataType: "json", 
       url: "kategoriler.php", 
       data: {name: $('#name').val() //ETC...}, 
       success: function (html) { 
       alert('ok'); 
       } 
     }); 
    }); 
+0

** onkeyup ** op想要提交表单在这个事件。 – Jai

+0

当我按下任何按钮时,此方法将工作? –

+1

我编辑我的文章;) –

0

,你可以不喜欢这样。前提是你whant提交表单在任何KEYUP

//trigger form submit 
$(document).keyup(function(){ 
    $("form").submit(); 
}); 

//Do what you whant with your form 
$("form").submit(function(){ 
    //Do something eg. ajax call 
     $.ajax({ 
      type: "POST", 
      dataType: "json", 
      url: "kategoriler.php", 
      data: {name: $('#name').val() //ETC...}, 
      success: function (html) { 
       alert('ok'); 
      } 
     }); 
}); 
+0

我有没有提交按钮,我想处理,当我按任何按钮? –

+0

好的。但当用户在文本框中输入内容时,这不是问题吗?这意味着表单会针对每个角色提交。在我看来,它会更方便onChange()。 –

+0

我怎样才能得到这个值:) –