How to Write a swing in JavaScript to insert data into the database

Source: Internet
Author: User

The final goal is to write a swing in JavaScript to determine whether to cancel the function, but there is a problem during the execution, during each execution, the data is directly inserted into the database, and cannot be controlled. To learn how to solve this problem, refer to the following code details for details: Copy codeThe Code is as follows: <%
Boolean foo = false;
If (theqingjiadays <3) & (thetiqiandays> = 1) | (theqingjiadays <10)
& (Theqingjiadays> = 3) & (thetiqiandays> = 3) | (theqingjiadays> = 10) & (thetiqiandays> = 7 ))){
Foo = true;
} Else {
// Do you want to continue without asking for leave in advance as required?
%>
<Script>
Var select = confirm ('Leave is not performed in advance as required. Continue? ');
If (select = true ){
Foo = true;
}
If (select = false ){
Foo = false;
Window. location. href = "qingjiaquxiao. jsp? Id = <% = qj. getId () %> ";
}
</Script>

You want to replace the script with a Swing window and cancel it to determine whether to execute the script, because the code in <%> is always executed first, the data will be inserted directly into the database and cannot be controlled.Copy codeThe Code is as follows: <%
}
}
// Insert a database
If (foo = true ){
Try
{

Insert statementCopy codeThe Code is as follows: qingjiaDAO. addQingJiaInfo (qj );
QingjiaDAO. addQingJiaMingxi (qjmingxi );
QingjiaDAO. updateQingJiaInfo (qj );
}
Catch (InfrastructureException ie ){
Out. println (ie. toString ());
}
Finally {
HibernateUtil. commitTransaction ();
HibernateUtil. closeSession ();
}
}

%> How can I implement a swing code in java to control this module? What I want to know is whether the script can pass the parameters of this page through window. location. href to another page?
Later, I saw on the Internet that I wanted to implement the above transfer. I could simulate the get commit and get the link on another page to analyze and obtain the parameters.
I tried it according to this thinking, but it was not implemented. The key was that I could not do it myself, but I solved the problem myself later, later I found that too many parameters were passed by myself, and some modifications were made below, as shown in the following details:Copy codeThe Code is as follows: window. location. href = "qingjiaapplysave. jsp? Qingjiatypeid = <
% = Request. getParameter ("qingjiatypeid") %>
&
Figure = <
% = Request. getParameter ("figure") %>
&
Qingjiastartdate1 = <
% = Request. getParameter ("qingjiastartdate1") %>
&
Qingjiaenddate1 = <
% = Request. getParameter ("qingjiaenddate1") %>
&
Reason = <
% = Request. getParameter ("reason") %>
&
Startdaterange1 = <
% = Request. getParameter ("startdaterange1") %>
&
Enddaterange1 = <
% = Request. getParameter ("enddaterange1") %> ";

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.