The solution to the problem is that, for a domain that needs to send large data, the data is split into a number of smaller than the limit before submitting the form, placed in several hidden fields, and emptied of the original field, then formally submits the form. Server-side or with Request.Form () read the data of each hidden field, and then in order to put them together on the line. The main code is as follows:
Note: You need to specify a div within the HTML code in the form to dynamically insert the hidden field into it.
= = = Client Sample Code = = =
Add in the HTML code in form: <div Id=divhidden></div>, add in the form tag: onsubmit= "Return Fnprehandle", Replace the Bigfield in the following code with the name of the domain in your form that submits the large database.
JavaScript code
Copy Code code as follows:
<script language=javascript>
The data is split and placed in the corresponding hidden field, which fires in the form's onsubmit event
function Fnprehandle (MyForm)
{
var icount; How many fields are split into
var strdata; Raw data
var imaxchars = 50000;//The maximum number of characters in a field is limited to 50K, taking into account that Chinese characters are double-byte
var Ibottleneck = 2000000;//If the article is more than 2M words, you need to prompt the user
var strhtml;
Raw data
Strdata = MyForm.BigField.value;
If the article is really too long, you need to remind the user
if (Strdata.length > Ibottleneck)
{
If confirm ("the article you are publishing is too long, it is recommended that you split it into several sections and publish separately.") \ NAND If you insist on submitting, note that it will take a long time to commit successfully. \ n \ ndo you insist on submitting? ") = = False)
return false;
}
icount = parseint (strdata.length/imaxchars) + 1;
Hdncount record the number of subdomains that the original data field is split into
strhtml = "<input type=hidden name=hdncount value=" + icount + ">";
Generate HTML code for each child domain
for (var i = 1; I <= icount; i++)
{
strHTML = strhtml + "\ n" + "<input type=hidden Name=hdnbigfield" + i + ">";
}
Dynamically insert HTML code for each hidden field within div (Divhidden) in form
Document.all.divHidden.innerHTML = strhtml;
Assigning values to each subdomain
for (var i = 1; I <= icount; i++)
{
myform.elements["Hdnbigfield" + I].value = strdata.substring ((i-1) * Imaxchars, I * imaxchars);
}
Empty the original data field
MyForm.BigField.value = "";
}
</script>
Server-side sample code asp/visual Basic code
Copy Code code as follows:
<%
dim strdata
dim intfieldcount
dim i
Intfieldcount = request.form ("Hdncount")
for i=1 to intfieldcount
strdata = strdata & request.form ("Hdnbigfield" & i)
next
response.write strdata
%>