php - jquery.form: how to set more than one form in one page? -


I have a list of names with the "Delete" button, every line is a form and clicking on delete Must be updated in real time but do not work because I can only set one ID in this plugin (it actually runs when there is only one name in the list)

This is a Javascript function :

$ (document) .ready (function () {var options = {target: '#risposta', resetForm: true, success: function (showResponse) {$ ("# lista_categorie" ). Fade (2000), settimeout (function ({$ ('# risposta'). Fadeaut (1000);}, ("crawler"), show ('fast'), show ('sharp'); $ ('# risposta'). 5000);}}; $ ('#AvilinkGogoria') .jaxfarm (option);});

The HTML form is created with PHP:

 
id = "categorie_elimina.php? Id = $ line ['id']" method = "post" id = "avilinagette" <




& lt; p & gt; $ line ['name' ] & Lt; input type = "submit" id = "submit_pro" value = "amina" category = "amina" & gt; & Lt; / P & gt; & Lt; / Form & gt;

I should create a separate ID for each form (for example using the line ID), but I should tell the JS function that every form in this line contains that function Must adhere to:

  $ ('# elimina_categoria') ajaxForm (option).  

I have also used this code:

  $ ('' [id | = elimina_categoria] '). Ajaxform (option);  

But it works only on the first click, the second time it opens the PHP script. Hope you can help me, sorry for bad english

First of all:

Instead of making multiple forms with the same ID, There should be many forms with the class only. For id-attribute, the same value should be used only once. Example

  & lt; Form id = "elimina_categoria_1" class = "elimina_categoria" & gt; ... & lt; / Form & gt; & Lt; Form id = "elimina_categoria_2" class = "elimina_categoria" & gt; ... & lt; / Form & gt;  

Please use more than _1, _2 descriptive naming ... However, if possible.

When each form has the same class, you can call the form by using

  $ ('form.elimina_categoria').  

Second:

The script you are looking for is something like this.

  Function Administratoria () {Var aliminiform = $ (this) .parent () parent () .; // Choose the option of the button $ .post (aluminumform.val ('action')); // Call action defined by the form. Remove the form element from the // page return false; // Do not let the submit button submit the form. } $ (Document) .ready (function () {$ ('.imilana'). Tie ('click', amilantagoria);}); The script may not work in your current situation, but I hope this will help you move forward. You probably add fadein, fadeout effect and you want to see the results of the HTTP POST request before removing the form from the page. 


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -