How can I get all form names exists on a page using jquery??? can I use jquery input selector to find all forms on a page. for example I have a form on page like below
<form name="searchForm" id="searchForm" action="">
<input type="text" name="inputname" />
</form>
now i want to find the form name "searchForm" using jquery. so how can i do this??
please help me. thanks.
The serializeArray() method creates an array of objects (name and value) by serializing form values. This method can be used to get the form data.
To get all <form> elements in the document, use the document. forms collection instead.
Read this: http://docs.jquery.com/Tutorials:Getting_Started_with_jQuery
Your question is unclear: the first sentence sounds like you want to use jQuery to get a list of all form names on the page, but then you say you want to find "searchForm", implying you want to select a form that you already know the name of.
To get all form names and store them in an array:
var names = [];
$("form").each(function() {
names.push(this.name);
});
To select a form you already know the name of:
$('form[name="searchForm"]')
// or if the name is in a variable:
var name = "searchForm";
$('form[name="' + name + '"]')
Or you can just select by id:
$('#searchForm')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With