03-同一頁面中的多表單提交(jsp基本應用)

來源:互聯網
上載者:User
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%><html><head><title>同一頁面中的多表單提交</title><script type="text/javascript">function Mycheck() {if (form1.text1.value == "") {alert("請輸入表單內容!");form1.text1.focus();return;}form1.submit();}function Mycheck1() {if (form2.text2.value == "") {alert("請輸入表單內容!");form2.text2.focus();return;}form2.submit();}function Mycheck2() {if (form3.text3.value == "") {alert("請輸入表單內容!");form3.text3.focus();return;}form3.submit();}</script></head><body><form action="" ?formid=1 name="form1" method="post">表單1: <input type="text" name="text1" class="text"> <inputtype="button" name="submit1" value="提交" onclick="Mycheck();"></form><form action="" ?formid=2 name="form2" method="post">表單2: <input type="text" name="text2" class="text"> <inputtype="button" name="submit2" value="提交" onclick="Mycheck1();"></form><form action="" ?formid=3 name="form3" method="post">表單3: <input type="text" name="text3" class="text"> <inputtype="button" name="submit3" value="提交" onclick="Mycheck2();"></form><%String text1 = "";String text2 = "";String text3 = "";String message = "";if (request.getParameter("text1") != null) {text1 = request.getParameter("text1");message = "提交了第一個表單,提交內容為" + text1 + "";out.print(message);}if (request.getParameter("text2") != null) {text2 = request.getParameter("text2");message = "提交了第2個表單,提交內容為" + text2 + "";out.print(message);}if (request.getParameter("text3") != null) {text3 = request.getParameter("text3");message = "提交了第3個表單,提交內容為" + text3 + "";out.print(message);}%></body></html>

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.