javascript - targeting a specific form with serialize() -


After the following, which was not a joke, it is now an additional question that submitted a reusable jQuery form. That does not take away the user from that place.

Problem

The jQuery serialize () function displays all kinds of magic within a page, and the specific form Not who was presented. Example code below.

How can I capture the unique name / id of the form, and change the "form" inside $ ("form"). Serialize () with the name of the target form so that only the serial can be done?

Form code

  & lt; Form name = "contact" id = "contact" action = "" & gt; & Lt; Input name = "_ recipient" type = "hidden" value = "joe@fake.com" /> & Lt; Input name = "_topics" type = "hidden" value = "title" /> ... & lt; Fieldset & gt; & Lt; Label = "name" id = "name_label" & gt; Name & lt; / Label & gt; & Lt; Input type = "text" name = "name" id = "name" size = "30" value = "" class = "text-input" /> & Lt; = "Name" id = "name_error" for label class = "error" & gt; This field is required. & Lt; / Label & gt; & Lt; Br / & gt; & Lt; Label = "email" id = "email_label" & gt; Return email & lt; / Label & gt; & Lt; Input type = "text" name = "email" id = "email" size = "30" value = "" class = "text-input" /> & Lt; Label class = "email" id = "email_error" for "error" & gt; This field is required. & Lt; / Label & gt; & Lt; Br / & gt; & Lt; Label = "phone" id = "phone_label" & gt; Return phone & lt; / Label & gt; & Lt; Input type = "text" name = "phone" id = "phone" size = "30" value = "" class = "text-input" /> & Lt; Label class = "error" for "error" = "phone" id = "phone_error" & gt; This field is required. & Lt; / Label & gt; & Lt; Br / & gt; & Lt; Br / & gt; & Lt; Input type = "submit" name = "submit" class = "button" id = "submit_btn" value = "send your suggestion" /> & Lt; / Fieldset & gt; & Lt; / Form & gt;  

jQuery series and posts

  var dataString = $ ("form"). Serialize (); // warning (datastring); Return false; $ .jax ({type: "post", url: "/_global/assets/scripts/formmail/formmail.asp", data: datestring, ...  

  var dataString = $ ('# contact'). Serialize ()  

If you attach If you are an event handler for a button or a form of submit event, you can refer to it with this if submit Event handler function scope, example

  $ ('# contact'). Submit (function () (warning ($ (this). Serialize ());})  

I Fie would recommend reading


Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -