Form submits some trick of the array, and form array trick

Source: Internet
Author: User

Form submits some trick of the array, and form array trick


Form
Use $. post (
"/Member/book/" + event_id,
{
Tickets: tickets,
Csrf_ppw_token: csrf_ppw_token,
Event_id: event_id,
},
You can pass tickets values to an array of objects.
Browser caputure is
Tickets [0] [fullname]:
Tickets [0] [telephone]:
Tickets [0] [email]:
Tickets [0] [company]:
Tickets [0] [role]:
Tickets [0] [cat_id]: 1
Tickets [1] [fullname]: B
Tickets [1] [telephone]:
Tickets [1] [email]:
Tickets [1] [company]:
Tickets [1] [role]:
Tickets [1] [cat_id]: 1
Csrf_ppw_token: 575b56d0fa9aba282a0f0e4e8dc14c86
Event_id: 1
The server can also use _ post ["tickets"] to obtain this data, but it is not an array of objects, but a two-dimensional array.

When using jquery form, you can manually process formdata,
Var temp = new Object ();
Temp. name = "tickets ";
Temp. value = tickets ;.

The objects uploaded at this time are all stored in the browser caputure
Tickets: [object Object], [object Object]


In this case, assign values using the following method:
Var ticket = new Object ();
Ticket. name = "tickets [" + I + "] [fullname]";
Ticket. value = $ (this). find ($ ("[name = 'fullname']"). val ();
FormData. push (ticket );


Formdata is an array of objects.


Array problems in form

Will not get such an array ..

Do not use arrays... use arr...

After you submit it, use request ("arr ")
You will get the selected value ..

Form submission

Map map = request. getParameterMap ();
Set set = map. keySet (); // set Set of all parameter names
Iterator it = set. iterator ();
While (it. hasNext ()){
String s = (String) it. next (); // an enumeration Parameter
String values [] = request. getParameterValues (s); // obtain the array returned by the corresponding parameter value
Then perform the operations you want, such
For (int I = 0; I <values. length; I ++ ){
Out. println (values [I]);
}
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.