我是靠谱客的博主 魁梧睫毛膏,最近开发中收集的这篇文章主要介绍mysql+点击+传值_js实现点击按钮传值,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

page1源码:

function newDoc() {

window.location.assign("hellow.html")

}

function quzhi() {

var text1 = document.getElementById("name").value; //取得文本框的值

var text2 = document.getElementById("password").value;

alert(text1);//网页提示框

alert(text2);

var myurl = "Test_01" + "?" + "pname=" + text1 + "&password=" + text2;

window.location.assign(encodeURI(myurl))

}

function quzhi2() {

var text1 = document.getElementById("name").value; //

var text2 = document.getElementById("password").value;

var myurl = "hellow.jsp" + "?" + "pname=" + text1 + "&password="+ text2;

window.location.assign(encodeURI(myurl))

}

page2源码:

Insert title here

hellow world!

page3源码:

Insert title here

String strName=request.getParameter("pname");

String strPassword=request.getParameter("password");

%>

欢迎您!

您的密码是:

servlet源码:

package test;

import java.io.IOException;

import javax.servlet.ServletException;

import javax.servlet.annotation.WebServlet;

import javax.servlet.http.HttpServlet;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

/**

* Servlet implementation class Test_01

*/

@WebServlet("/Test_01")

public class Test_01 extends HttpServlet {

private static final long serialVersionUID = 1L;

/**

* @see HttpServlet#HttpServlet()

*/

public Test_01() {

super();

// TODO Auto-generated constructor stub

}

/**

* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)

*/

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

// TODO Auto-generated method stub

response.getWriter().append("Served at: ").append(request.getContextPath());

String strName=request.getParameter("pname");

String strPassword=request.getParameter("password");

System.out.println(strName);

System.out.println(strPassword);

}

/**

* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)

*/

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

// TODO Auto-generated method stub

doGet(request, response);

}

}

运行后图片

最后

以上就是魁梧睫毛膏为你收集整理的mysql+点击+传值_js实现点击按钮传值的全部内容,希望文章能够帮你解决mysql+点击+传值_js实现点击按钮传值所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(51)

评论列表共有 0 条评论

立即
投稿
返回
顶部