Home > Web Front-end > JS Tutorial > How to write a swing in JavaScript to insert data into the database_Basic knowledge

How to write a swing in JavaScript to insert data into the database_Basic knowledge

WBOY
Release: 2016-05-16 17:47:05
Original
898 people have browsed it

The ultimate goal is to write a swing in JavaScript to implement confirmed cancellation and decide whether to execute this function. However, during the execution process, a problem occurred. Every time it is executed, it will be inserted directly. Inserting data into the database is out of control. If you want to know how to solve this problem, please refer to the code details below:

Copy code The 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{
//Failed to ask for leave in advance as required, do you want to continue
%>
<script> <br>var select=confirm('Failed to ask for leave in advance as required, do you want to continue?'); <br>if(select==true){ <br>foo=true; <br>} <br>if(select==false){ <br>foo=false; <br>window.location.href=" qingjiaquxiao.jsp?id=<%=qj.getId()%>"; <br>} <br></script>

I want to replace this script with a Swing one Window, implement confirmation and cancellation to decide whether to execute, because each execution always executes the code in <% %> first, and then directly inserts the data into the database, which is out of control
Copy code The code is as follows:

<%
}
}
//Insert into the database
if(foo==true){
try
{

Insert statement
Copy code The 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();
}
}

%>A piece of swing code in java is needed to control this module. How to implement it? And what I want to know is whether it is possible to pass the parameters of this page to another page through window.location.href through a script?
Later I saw on the Internet that if you want to achieve the above transfer, you can simulate get submission, and analyze and obtain the parameters after getting the link on another page.
I tried following this idea, but it didn’t work. The key was that I didn’t know how to do it. However, I later solved the problem myself because I later found out that I passed too many parameters myself. Here are the following Made some modifications, the following details:
Copy the code The 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 labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template