JavaScript in form.submit () does not respond to questions submitted

2009-05-06  来源:本站原创  分类:AJAX  人气:988 

<%@ page language="java" import="java.util.*"  contentType="text/html;charset=gb2312"%>
<%@ page language="java" import="com.fredck.FCKeditor.*" %>
<%@ taglib uri="/WEB-INF/FCKeditor.tld" prefix="FCK" %>
<jsp:useBean scope="page" />
<jsp:useBean scope="page" />
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String dir=sn.getDir();
%>
<HTML><HEAD><TITLE> A background operation area  </TITLE>
<LINK href="<%=basePath %><%=dir %>/images/Admin_Style.css" type=text/css rel=stylesheet>
<LINK href="<%=basePath %><%=dir %>/images/style.css" type=text/css rel=stylesheet>
<script type="text/javascript" src="<%=path %>FCKeditor/fckeditor.js"></script>
<STYLE type=text/css>
BODY {
	MARGIN-LEFT: 0px; BACKGROUND-COLOR: #ffffff
}
.STYLE1 {color: #ECE9D8}
</STYLE>
</HEAD>
<script type="text/javascript">

function sub()
{
	var form = document.getElementById('form1');
	if(document.form1.name.value.replace(/\s+$|^\s+/g,"").length<=0||document.form1.age.value.replace(/\s+$|^\s+/g,"").length<=0
	||document.form1.tel.value.replace(/\s+$|^\s+/g,"").length<=0||document.form1.remark.value.replace(/\s+$|^\s+/g,"").length<=0
	||document.form1.address.value.replace(/\s+$|^\s+/g,"").length<=0)
	{
		alert(" All projects must be completed!  ");
		return false;
	}

	form.submit();
}
</script>
<%
String message = (String)request.getAttribute("message");
	if(message == null){
		message = "";
	}
	if (!message.trim().equals("")){
		out.println("<script language='javascript'>");
		out.println("alert('"+message+"');");
		out.println("</script>");
	}
	request.removeAttribute("message");
%>
<%
	String username=(String)session.getAttribute("user");
	if(username==null){
		response.sendRedirect(path+"/error.jsp");
	}
	else{
		String method=request.getParameter("method");
		if(method==null){
			method="addygzl";
		}
		//String wydz,String fx,String jzmj,String symj,String yzmc,String jg,String gzdw,String yb,
		//	String cwwz,String tczh,String wydz,String kssj,String jzsj,String bz
		String name = "";
		String age="";
		String tel="";
		String address="";
		String remark="";
		String;

		if(method.equals("upygzl")){
			id=request.getParameter("id").trim();
			List newsList=tb.getOneYg(Integer.parseInt(id));
			name=newsList.get(1).toString();
			age=newsList.get(3).toString();
			tel=newsList.get(4).toString();
			address=newsList.get(5).toString();
			remark=newsList.get(6).toString();
		}		

%>
<BODY onload="document.form1.infoContent.value=document.form1.content.value" >
<TABLE height="100%" cellSpacing=0 cellPadding=0 width="100%" border=0>
  <TBODY>
  <TR>
    <TD align="left" vAlign=top >
<table width='100%' cellspacing='1' cellpadding='3' bgcolor='#CCCCCC'>
<tr>
      <td colspan="2">
<%
	if(method.trim().equals("addygzl")){
%>
         Add employee information
<%}else{%>
	    Modify the employee information
<%} %>
      </td>
    </tr>
	<form name="form1" action="<%=basePath %>WyServlet" method="post" >
  <tr bgcolor='#FFFFFF'>
    <td width='30%'><div align="right"> The name of an employee:  <input type="hidden" name="method" value="<%=method %>"> <input type="hidden" name="id" value="<%=id %>"></div></td>
    <td ><input name="name" type="text" size="40" maxlength="100" value="<%=name %>"></td>
  </tr>
  <tr bgcolor='#FFFFFF'>
    <td width='30%'><div align="right"> Sex  &nbsp;&nbsp;&nbsp;&nbsp; Don't:  </div></td>
    <td ><input name="sex" type="radio"  value=" Male  " checked>  Male  <input name="sex" type="radio"  value=" Women  ">  Women  </td>
  </tr>
  <tr bgcolor='#FFFFFF'>
    <td width='30%'><div align="right"> Employees aged:  </div></td>
    <td ><input name="age" type="text" size="10" maxlength="100" value="<%=age %>"></td>
  </tr>
  <tr bgcolor='#FFFFFF'>
    <td width='30%'><div align="right"> Telephone:  </div></td>
    <td ><input name="tel" type="text" size="40" maxlength="100" value="<%=tel %>"></td>
  </tr>
  <tr bgcolor='#FFFFFF'>
    <td width='30%'><div align="right"> Contact address:  </div></td>
    <td ><input name="address" type="text" size="40" maxlength="100" value="<%=address %>"></td>
  </tr>
  <tr bgcolor='#FFFFFF'>
    <td width='30%'><div align="right"> Preparation  &nbsp;&nbsp;&nbsp;&nbsp; Note:  </div></td>
    <td ><textarea name="remark" cols=40 rows=5><%=remark %></textarea></td>
  </tr>
  <tr bgcolor='#FFFFFF'>
      <td colspan="2" align="center">
        <input'button' name='button' value=' Submit data  '>
      </td>
    </tr>

</table>
</form>
   </TD>
	</TR>
  </TBODY>
</TABLE>
</BODY>
<%} %>
</HTML>

Shouted HELP ~ ah ~ ~ do not know why not submit submit, servlet category does not reflect, note web.xml in the relevant configuration information is accurate. ~ Graduation design anxious

相关文章
  • JavaScript in form.submit () does not respond to questions submitted 2009-05-06

    <%@ page language="java" import="java.util.*" contentType="text/html;charset=gb2312"%> <%@ page language="java" import="com.fredck.FCKeditor.*" %> <%@ taglib uri="/WEB-INF/FCKeditor.tld

  • form.submit purposes: to button submit laid off, replace the submit button action 2010-09-10

    form.submit purposes: to button submit laid off, replace the submit button action Under normal circumstances, submit the form to use the following code: <input name="submit" type="submit" value="k686 Green software " />

  • JavaScript and PHP to implement a form submit button way more than the source code 2010-10-29

    JavaScript and PHP to implement a form submit button way more than the source code Today, when doing the background to deal with a form, the form with two submit buttons, to achieve a different submit button when clicked, respectively, for two differ

  • javascript how to listen form.submit () event 2010-12-26

    Is well known, dynamic form submission (form.submit ()) can not trigger the onsubmit event. If you want to want to capture form.submit (), provides two solutions in this The first is: In form.submit () method to add form.fireEvent ("onsubmit");

  • IE6 issue of non-submission of Form.submit 2010-04-19

    Today, faced a very interesting question. From the data submitted with the First, with the <input type="submit"/> button, one through the JavaScript script: formElement.submit (). No matter which approach is very simple. But today I was in

  • form submit拦截 表单提交拦截 2011-05-30

    [code] <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

  • javascript validate form 2010-05-11

    A good use of javascript validate form of class library http://www.javascript-coder.com/html-form/javascript-form-validation.phtml

  • form of the form submit () method does not call the onsubmit event, not check 2010-06-12

    <form name="form1" method="post" action="a.html" onsubmit="return check()"> ... ... ... ... ... ... ... ... ... ... --------------------- <td colspan="3"> <input type="button" valu

  • extjs form submit in two ways 2010-09-11

    extjs form submit in two ways: One is the AJAX submission, the other is the traditional filing. The default is the AJAX submission. If you want to submit the traditional way to conduct the following settings (note the red part) Ext.onReady (function

  • JS中的form.submit()不能提交表单的错误原因 2013-10-01

    这篇文章主要介绍了JS中的form.submit()不能提交表单的错误原因,本文最后得出结论是按钮的ID.名称不要使用submit,需要的朋友可以参考下 直接上代码把: <div id="register"> <h4>会员注册</h4> <div class="formdiv"> <form method="post" action="register.php?action=regi

  • chrome不支持form.submit的解决方案 2014-01-15

    最近在解决项目中网站浏览器兼容性问题,发现chrome竟然不支持form.submit,经网上搜寻,终于找到了解决方案,有需要的小伙伴参考下. 最近看到Q群里有人说chrome(谷歌浏览器)不支持form.submit方法,求解决办法.闲的时候亲自测试了一番,发现chrome竟然真的不支持form.submit,测试的时候用的是Jquery的,也不支持,于是乎研究了半天,终于找到了一个解决办法. //获取form表单的id var form=$('#myform').val(); //获取浏览器

  • form.submit()不能提交表单的原因分析 2014-03-30

    这篇文章主要分析了form.submit()不能提交表单的原因,需要的朋友可以参考下 直接上代码把: <div id="register"> <h4>会员注册</h4> <div class="formdiv"> <form method="post" action="register.php?action=register" name="register&quo

  • javascript获取form里的表单元素的示例代码 2015-01-04

    本篇文章主要是对javascript获取form里的表单元素的示例代码进行了介绍,需要的朋友可以过来参考下,希望对大家有所帮助 //获取form对象 var form=document.getElementById('my_form'); //用户名input对象 user_name是对象的name属性 var userName=form.user_name; //用户名清空 userName.value=''; //用户密码input对象 password是对象的name属性 var pass

  • chrome不支持form.submit($('form').submit)的解决方案 2013-01-22

    最近在解决CSAIR官方网站浏览器兼容性问题,发现chrome竟然不支持form.submit,经网上搜寻,解决方案如下 /获取form表单 var form = $('#myform'); //获取浏览器参数 var browserName = navigator.userAgent.toLowerCase(); if (/chrome/i.test(browserName) && /webkit/i.test(browserName) && /mozilla/i.tes

  • The strange javascript issue, form the submit does not work, does not exist in the property or method 2010-07-23

    Funny to say, hey, can not help themselves secretly laugh Today, the debugger var s = document.getElementById('configForm'); s.submit(); Page error object does not exist in the property or method Change to change this, move it move, just do not know

  • extjs form submit success did not respond because 2010-05-07

    There are many reasons the main reason I say that the next, we may upload a file back to the success: true, but is damn useless, right? Depend, to find a long last to set the return header information for the text / html, and then on it. I faint

  • js form submit verification 2010-11-05

    <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <script type="text/javascript"

  • form.submit () can not submit form solution 2010-06-10

    Web development encounter, need to use js to submit form form. Found using document.form1.submit (); methods can not submit the form. Firefox prompted to submit is not a function. Finally find the solution. 1. The form can not have name = "submit&quo

  • non-ajax form submit 2010-07-15

    Ext.onReady(function(){ var form = new Ext.form.FormPanel({ labelAlign: 'right', title: 'form', frame:true, url: '/extdo/extWinFormSave.do', width: 280, items: [{ xtype: 'textfield', fieldLabel: ' Text ', name: 'text' },{ xtype: 'numberfield', fieldL

  • jquery form submit reset 2010-09-01

    $ ('# Myform'). Submit () form submission $ ('# Myform') [0]. Reset () form submission $ ('# Myform'). Reset () This is wrong, reset can not be achieved