Reading/submitting a form with variable-length sets of fields, read as an array server-side

Asked
Active3 hr before
Viewed126 times

6 Answers

fields
90%

This is the form HTML I'm working with:, Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers ,I want to be able to deal with these submissions as a two dimensional array server side, something like:, Is knowing music theory really necessary for those who just want to play songs they hear?

for the first venue:

name = "data[0][venue_name]"
load more v
88%

Form fields do not necessarily have to appear in a <form> tag. You can put them anywhere in a page. Such fields cannot be submitted (only a form as a whole can), but when responding to input with JavaScript, we often do not want to submit our fields normally anyway.,A button with a type attribute of submit will, when pressed, cause the form to be submitted. Pressing Enter when a form field is focused has the same effect.,When a form is submitted, its "submit" event fires. A JavaScript handler can call preventDefault on that event to prevent the submission from happening. Form field elements do not have to be wrapped in <form> tags.,The <label> tag is used to associate a piece of text with an input field. Its for attribute should refer to the id of the field. Clicking the label will activate the field, which focuses it and toggles its value when it is a checkbox or radio button.

Form fields do not necessarily have to appear in a <form> tag. You can put them anywhere in a page. Such fields cannot be submitted (only a form as a whole can), but when responding to input with JavaScript, we often do not want to submit our fields normally anyway.

<p><input type="text" value="abc"> (text)</p>
<p><input type="password" value="abc"> (password)</p>
<p><input type="checkbox" checked> (checkbox)</p>
<p><input type="radio" value="A" name="choice">
   <input type="radio" value="B" name="choice" checked>
   <input type="radio" value="C" name="choice"> (radio)
</p>
<p><input type="file"> (file)</p>
load more v
72%

The following sections explain how user agents submit form data to form processing agents.,Form submission method,Processing form data Step one: Identify the successful controls Step two: Build a form data set Step three: Encode the form data set Step four: Submit the encoded form data set ,When the user submits a form (e.g., by activating a submit button), the user agent processes it as follows.

Here's a simple form that includes labels, radio buttons, and push buttons (reset the form or submit it):

 <FORM action="http://somesite.com/prog/adduser" method="post">
    <P>
       <LABEL for="firstname">First name: </LABEL>
       <INPUT type="text" id="firstname"><BR>
       <LABEL for="lastname">Last name: </LABEL>
       <INPUT type="text" id="lastname"><BR>
       <LABEL for="email">email: </LABEL>
       <INPUT type="text" id="email"><BR>
       <INPUT type="radio" name="sex" value="Male"> Male<BR>
       <INPUT type="radio" name="sex" value="Female"> Female<BR>
       <INPUT type="submit" value="Send"> <INPUT type="reset">
    </P>
 </FORM>
load more v
65%

Client/server architecture,On the server side: retrieving the data,Server-side website programming first steps,Note: Servers can be configured with a size limit for files and HTTP requests in order to prevent abuse.

<form action="https://example.com">
load more v
75%

HTML forms use either GET or POST to send data to the server. The method attribute of the form element gives the HTTP method:,Now let's write an HTML form for users to submit a status update.,Notice that the action attribute on the form is the URI of our controller action. Here is the form with some values entered in:,Before sending a simple type, consider wrapping the value in a complex type instead. This gives you the benefits of model validation on the server side, and makes it easier to extend your model if needed.

HTML forms use either GET or POST to send data to the server. The method attribute of the form element gives the HTTP method:

<form action="api/values" method="post">
load more v
40%

When making a request to the server using server-side processing, DataTables will send the following data in order to let the server know what data is required:,Once DataTables has made a request for data, with the above parameters sent to the server, it expects JSON data to be returned to it, with the following parameters set:,For further information about the Ajax options available in DataTables, please refer to the ajax documentation.,In addition to the above parameters which control the overall table, DataTables can use the following optional parameters on each individual row's data source object to perform automatic actions for you:

Server-side processing in DataTables is enabled through use of the serverSide option. Simply set it to true and DataTables will operate in server-side processing mode. You will also want to use the ajax option to specify the URL where DataTables should get its Ajax data from. As such, the simplest server-side processing initialisation is:

$('#example').DataTable({
   serverSide: true,
   ajax: '/data-source'
});
load more v

Other "fields-undefined" queries related to "Reading/submitting a form with variable-length sets of fields, read as an array server-side"