user1697964
user1697964

Reputation: 11

How can I submit a form in Yii whenever a textfield changes?

I am actually coding a website using Yii framework. I have a view with several tables, each containing a form with a unique id. Each form has a textfield, and 2 dropdownlists. Each form must be submitted when the textfield onkeyup event is triggered and when each dropdownlist onchange event is triggered.

Note that for the onkeyup event, you must wait for around 500 ms before submitting the form.

Upvotes: 0

Views: 1438

Answers (1)

Elbek
Elbek

Reputation: 3484

just write js function.

$('input[type=text]').keyup(function(){
   setInterval(function(){
     $(this).closest("form").submit();
      },500);
})

$("select").change(function(){
    $(this).closest("form").submit();
})

I suggest you ta have same classes for input[type=text] and for dropdowns. so it will be more easy for select.

Upvotes: 1

Related Questions