How to write a swing in JavaScript insert data into the database _ basics

Source: Internet
Author: User
The ultimate goal is to write a swing in JavaScript to determine whether or not to perform this function, but in the process of execution, there is a problem, and each time it is executed, it is inserted directly into the database and is not controlled. To find out how to solve this problem, refer to the following code details:
Copy Code code as follows:

<%
Boolean foo=false;
if ((theqingjiadays<3) && (thetiqiandays>=1) | | ((THEQINGJIADAYS<10)
&& (theqingjiadays>=3) && (thetiqiandays>=3) | | ((theqingjiadays>=10) && (thetiqiandays>=7)) {
Foo=true;
}else{
Not in advance of the prescribed leave, whether to continue
%>
<script>
var select=confirm (' Not required to leave early, whether to continue? ');
if (select==true) {
Foo=true;
}
if (Select==false) {
Foo=false;
Window.location.href= "Qingjiaquxiao.jsp?id=<%=qj.getid ()%>";
}
</script>

To replace the script with a swing window, implement the Cancel to determine whether to execute, because each execution always executes the code in the <%%>, and inserts the data into the database directly, without controlling the
Copy Code code as follows:

<%
}
}
Insert Database
if (foo==true) {
Try
{

Insert statement
Copy Code code as follows:

Qingjiadao.addqingjiainfo (QJ);
Qingjiadao.addqingjiamingxi (Qjmingxi);
Qingjiadao.updateqingjiainfo (QJ);
}
catch (Infrastructureexception IE) {
Out.println (Ie.tostring ());
}
finally{
Hibernateutil.committransaction ();
Hibernateutil.closesession ();
}
}

%> needs a piece of Java Swing code to control the module, how should it be implemented? And what you want to know is whether you can pass the parameters of the page through Window.location.href to another page via a script?
Later on the Internet to see that is to achieve the above pass, you can simulate get submit, in another page after the link analysis to obtain parameters.
According to this thinking to try, but did not achieve, the key is not how to do it, but then I solved the problem myself, because later found that I have passed too many parameters, the following has made a partial change, such as the following details:
Copy Code code 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.