修改数据库的数据,可是结果会出现undefined,是为什么啊[b][/b]
<%@page import="java.util.List"%>
<%@page import="cn.com.chengang.InsertAndSelect"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!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=ISO-8859-1">
<title>Update title here</title>
<% String id=request.getParameter("id");
String sql="select * from test_table where id="+id;
List<String> vals = new InsertAndSelect().query(sql);
String name0="";
String name1="";
String name2="";
if(vals!=null&&vals.size()==1){
String val = vals.get(0);
String[] strs = val.split("_");
name0=strs[1];
name1=strs[2];
name2=strs[3];
}
%>
<script type="text/javascript">
function update(id){
alert(id);
var name0=document.getElementById("name0").value;
var name1=document.getElementById("name1").value;
var name2=document.getElementById("name2").value;
document.location.href="firstmysql.jsp?action=update&name0="+name0+"&name1="+name1+"&name2="+name2+"&id="+id;
}
</script>
</head>
<body>
<table>
<tr>
<td>name0:</td>
<td><input name="name0" id="name0" value="<%=name0 %>"></td>
</tr>
<tr>
<td>name1:</td>
<td><input name="name1" id="name1" value="<%=name1 %>"></td>
</tr>
<tr>
<td>name2:</td>
<td><input name="name2" id="name2" value="<%=name2 %>"></td>
</tr>
<tr>
<td><input type="button" value="submit" onclick="update(id)"> </td><td><input type="reset"> </td>
</tr>
</table>
</body>
</html>
------解决方案--------------------------------------------------------
- HTML code
><input type="button" value="submit" [color=#FF0000]onclick="update(id)"[/color]> </td><